This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Wanted: Sample JDBC 4 with SQL Annotation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Wanted: Sample JDBC 4 with SQL Annotation" Watch "Wanted: Sample JDBC 4 with SQL Annotation" New topic

Wanted: Sample JDBC 4 with SQL Annotation

Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 396
I'm trying to run the sample code in "A Tutorial Java 6 New Features" by Budi Kurniawan page 167. The code for the book is available at Chapter 8 is the database chapter.

Neither the java command line javac nor the java6 compiler used by eclipse can find the class java.sql.DataSet.

What do I have to do to make to compile the following code?

Better yet, does someone have some sample JDBC4 code that demonstrates using annotations for SQL queries (insert, delete, select, update etc...) that compiles and runs?

I did some google searching and found some JDBC4 tutorials, but the code fragments did not include the import statements!

I was told that the only low cost database that includes a JDBC4 driver is IBM's Apache Derby. Is this true?


package jdbcDemo;
import java.sql.Connection;
import java.sql.DataSet;
import java.sql.DriverManager;
import java.sql.SQLException;

public class QueryDemo {

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 44048
I have looked in the J2SE and J2EE APIs and there is no sign of a Dataset class. Please check carefully that it really is java.sql.DataSet you are looking for.
The Apache Derby database is usually included with Java 6 SDK downloads.
Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 396
Well, OK, how about an example that uses that new feature where you specify the SQL in an annotation? Can someone point me to a working example of that feature?

I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Wanted: Sample JDBC 4 with SQL Annotation
It's not a secret anymore!