JDBC Section Index
How can I get a pooled connection?
If the DataSource supports pooling connections, calling getConnetion() on the source will return a PooledConnection, instead of a plain Connection. The DataSource will implement ConnectionPoolData...more
How can I get a pooled connection?
If the DataSource supports pooling connections, calling getConnetion() on the source will return a PooledConnection, instead of a plain Connection. The DataSource will implement ConnectionPoolData...more
How can you find the cause of a SQL exception?
There are three areas where exception handling your JDBC code has improved with the changes in JDBC 4.0. First off, you can use the Java 5 for-each loop to easily iterate through the cause of an e...more
How do I check if a Connection is still valid / has been closed?
With JDBC 4.0, you can call the isValid(int timeout) method. The timeout represents the number of seconds to wait for a reply. If no reply is acquired during the time, false is returned and the ca...more
How do I setup my JDBC driver to be automatically loaded in Java 6?
Place the name of your java.sql.Driver implementation in the file META-INF/services/java.sql.Driver.
What's the difference between a transient and non-transient JDBC exception?
When making a JDBC call, an exception may happen. If performing the same task could succeed without changing anything, that exception is transient. For instance, a timeout is a type of transient e...more
When was national character set support added to JDBC?
National character set support is part of the JDBC 4.0 specification. It didn't quite make it into Java SE 6.0, though was available in early betas.
When was national character set support added to SQL?
This is part of the SQL 2003 specification.
Where can I read up more on JDBC 4.0?
JDBC 4.0 is defined by JSR 221. Information is available through its JCP home at http://www.jcp.org/en/jsr/detail?id=221.
What is Derby?
Derby is an open source relational database from Apache that is implemented entirely in Java and available under the Apache License. You can get it from http://db.apache.org/derby/.more
How do I load a database driver with JDBC 4.0 / Java 6?
Provided the JAR file containing the driver is properly configured, just place the JAR file in the classpath. That's it. No need to manually load the class or register the driver.
How do I loop through all the causes of a SQLException?
You can call the getCause() method of the exception repeatedly
try {
...
} catch (SQLException sqle) {
for(Throwable t : sqle) {
System.out.println("Throwable: " + t);
Throwable ca...more
How do I loop through the causes of a SQL Exception?
You can repeatedly call getCause() of the SQLException:
try {
...
} catch (SQLException sqle) {
for(Throwable t : sqle) {
System.out.println("Throwable: " + t);
Throwable cause = t...more
How do you access the SQL row ID?
Using ROWID as the column name in the query, you can use the Java 6 getRowId(columnNum) method.
Using Java 6, how do you loop through the causes of a SQL Exception?
The SQLException class is now Iterable in Java 6.
try {
...
} catch (SQLException sqle) {
for(Throwable t : sqle) {
System.out.println("Throwable: " + t);
}
}
more