jdbc

spring JDBC

I am getting the following exception whe using derby to do a UPDATE in oracle Database org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.derby.client.am.DisconnectException: A communication error has been detected. Communication protocol being used: Reply.fill(). Com...

Deconstruct an SQL Statement in Java

I have some legacy SQL and I want to split it up into it's constituent parts & then add more criteria, an order by clause, etc. Are there any existing Java libraries out there that interpret SQL like this? So I want to do something like deconstructedSQL.getCriteria().add("price > 100"); or deconstructedSQL.getOrderBy().add("price")...

Behaviour of ResultSet after connection got corrupted.

Suppose I am making jdbc call and I had fetched data from db to resultset. But due to some network issue I lost my connection with db. (Connection, statement and resultset is not closed in DB). So can I still able to iterate resultset ? ...

In JDBC, when to use Time, Date, and Timestamp

JDBC offers me 3 different datatypes for time-related fields: "Date", "Time" and "Timestamp". Can someone provide a simple summary of what each one is used for and how to choose which to use for a given problem? ...

Spring, JDBC & MultiThreading

Which datasource best supports multi-threading in Spring? ...

Suspend weblogic datasource on command line

I was Wondering if there is anyway of suspending / resuming weblogic 10 jdbc datasources via the command line. I am aware that i can do this in the admin console, but because our app has many different datasources it is a bit of a pain. The reason behind this is that our testers are doing error flow tests and have to simulate the db goi...

sql server query running slow from java

I have a java program that runs a bunch of queries against an sql server database. The first of these, which queries against a view returns about 750k records. I can run the query via sql server management studio, and I get results in about 30 seconds. however, I kicked off the program to run last night. when I checked on it this mor...

executeQuery() not returning.

Is there any condition under which PreparedStatement.executeQuery() does not return ro throw an exception ? ...

Why do I need a connection to create PreparedStatements ?

I would like to use prepared statements, for many reasons. But, I would like to create a method that looks like this: /* This opens a connection, executes the query, and closes the connection */ public static void executeNonQuery(String queryString); In other words, I want my application logic to only have to formulate the queries and...

JDBC DAO - any good reference implementation?

Can anyone point me to a well written DAO using JDBC, that covers all the exceptions a DAO should handle. I looked at some samples at java.sun.com, their blue prints but there is a lot of theory and less code. Looking through Spring DAO source code will be enlightening but that's way too complicated for me. ...

Connect to a secure database using JDBC

How do you specify the username and password for a JDBC connection when acessing a secure database? ...

How does JDBC use abstract factory?

Hi I got an exam in two days and one of the questions is how JDBC uses the abstract factory. I myself is not so skilled with design patterns, so maybe somebody here had the answer. I was thinking that maybe, DriverManager.getConnection(url) is an example of abstract factory, but am not sure. Or is it a factory method? ...

"Unexpected pre-login response" error received when connecting JDBC to SQL Server 2005

I've got an application written in Java (JRE 1.6) using the latest SQL Server 2.0 JDBC driver. A user is running this application remotely on their Windows Server 2003 machine, trying to connect to an instance of SQL Server 2005. When they try to connect, they get the following error message "The driver received an unexpected pre-login...

Set language for Oracle JDBC thin client

I want to specify language for the JDBC connection before it is actually created. For example if I specify wrong L/P credentials in DriverManager.getConnection(url, user, password) I need to get ORA error localized to the language I selected. I use Oracle thin client and setting NLS_LANG environmental variable did not work. :-( ...

If I use jRuby, Ruby on Rails, and JDBC, can I still use an ORM?

Can I use Hibernate, for example? Active Record? I have to use jdbc for an older database so I have to use jRuby with Ruby on Rails. Thank you. ...

ThreadLocal + java.sql.Connection + servlet filter = 2009?

I am writing some servlets with plain old mostly-JDBC patterns. I realized that I have several objects that would like to share a single transaction, and I'd like to enforce that one HTTP transaction = one database transaction. I think I can do this via passing a Connection around in a ThreadLocal variable, and then having a servlet fil...

Different results from .mdb vs .odb, why?

I use the following query to retrieve data from a .mdb file through JDBC, however when I try it on an .odb file it goes does not throw any exceptions but there are no results at all. I am wondering is .odb case sensitive where .mdb is not or is there something else I am missing? "SELECT DISTINCT column-one + ':' + column-two As ResultCo...

Java JDBC Lazy-Loaded ResultSet

Is there a way to get a ResultSet you obtain from running a JDBC query to be lazily-loaded? I want each row to be loaded as I request it and not beforehand. ...

Does CachedRowSet work with all ResultSet implementations?

I'm trying to implement a database paging solution (forward only required) using a CachedRowSet to page an AS400JDBCResultSet containing the results of my query. I've tried using the CachedRowSet cachedRowSet = new CachedRowSetImpl(); cachedRowSet.setMaxRows(10); cachedRowSet.setPageSize(10); cachedRowSet.populate(resultSet); approac...

hibernate mapping for postgresql "timestamp without time zone"?

I'm trying to map java.util.Date to postgresql timestamp without time zone type. I'm using a custom sql-insert statement (because the table is partitioned and postgresql won't return number of rows updated on a normal insert), and I keep getting an error saying the function does not exist. I suspect this is due to a problem mapping the...