Summary:
JDBC 4 is the forthcoming release of the Java Database Connectivity API. Currently in Early Draft Review in the JCP (JSR 221), JDBC 4 is a major new release with a strong focus on ease-of-use and programmer productivity. The new JDBC version also introduces support for SQL 2003 data types, including SQL's native XML type. This article surveys the key JDBC 4 features.
The ability to add new comments in this discussion is temporarily disabled.
Most recent reply: August 17, 2006 11:39 PM by
joe
|
JDBC 4 is the forthcoming release of the Java Database Connectivity API. Currently in Early Draft Review in the JCP (JSR 221), JDBC 4 is a major new release with a strong focus on ease-of-use and programmer productivity, and support for SQL 2003 data types, including SQL's native XML type. This article surveys the key JDBC 4 features. http://www.artima.com/lejava/articles/jdbc_four.htmlWhat do you think of the new JDBC 4 features?
|
|
|
Interesting.
Is any vendor planing to do a JDBC 4 driver?
.V
|
|
|
JDBC 4 is still in early draft review, which means it isn't a fully released standard yet. In fact, you are free to download the spec and comment on it, if you're interested. Once it becomes a fully approved JSR, vendors will no doubt start implementing JDBC4 - compliant drivers.
|
|
|
Do we finally get multi-line (verbatim) string literals? Where you can't have escape sequences. Like the following:
Connection c = myDataSource.getConnection(); PreparedStatement st = c.prepareStatement(""" insert into siteusers (userid, username) values (?, ?) """; st.setRowId(1, rowId1);
Here """ would mean that start of the string is in the next line, so that the beginning of the string would be properly intended. Here the resulting string would be:
insert into siteusers (userid, username)\nvalues (?, ?)
|
|
|
I doubt it since this has nothing to do with JDBC. But, if you want that feature, check out Groovy: http://groovy.codehaus.org/Strings
|
|
|
In the Type-safe querying and results code that you show, you never describe how the actual binding happens. How does the system decide that when it runs the query defined in the annotation that it is going to create a DataSet of User objects? How does it know that each row of the query is going to be mapped into a User object and what fields on the database are to be mapped to each field on the object? The fields may be associated by naming convention, but there seems to be something missing from the example that binds the User object to the user table. interface MyQueries extends BaseQuery {
@Query(sql="select * from user")
DataSet getAllUsers();
}
.
.
.
Connection c = myDataSource.getConnection();
MyQueries myQueries = c.createQueryObject(MyQuery.class);
DataSet users = myQueries.getAllUsers();
for (User u: users) {
System.out.println("User's name is: " + user.name;
}
|
|
|
> The fields may be associated by naming convention, but > there seems to be something missing from the example that > binds the User object to the user table.
From the JDBC4.0 spec pdf:
[...] public class Mammal { public String firstName; public String lastName; public int age; public int weight; public String description; } [...] Methods decorated by Select annotations will return instances of DataSet<T>.
interface MyQueries extends BaseQuery { @Select(sql="SELECT lastName, description FROM mammal") DataSet<Mammal> getAllMammals(); [...]
DataSet<T> is your answer.
|
|
|
I'm literally drooling about the new JDBC 4 features. I almost wet my pants when I saw the Type Safe DataSets. I can't wait to be able to use this in production. Way Cool!!
|
|
|
JDBC 4.0 Enhancements in Java SE 6. Auto-loading Driver is good feature. In JDBC 4.0, we don't need the Class.forName() line. http://www.developerzone.biz/
|
|