How to run JDBC 4 Demo?

I'm trying to run the sample code in "A Tutorial Java 6 New Features" by Budi Kurniawan page 167.

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?

Thanks,

Siegfried

package jdbcDemo;

import java.sql.Connection;

import java.sql.DataSet;

import java.sql.DriverManager;

import java.sql.SQLException;

public class QueryDemo {

}

[520 byte] By [siega] at [2007-11-27 10:38:33]
# 1

I doubt anyone in the group specifically used that tutorial and can answer your question directly. However, my guess is that it cant find java.sql.DataSet class because its not a class that can be instansiated. jva.sql.DataSet is interface (interfaces cant be instansiated). Instead some class has to implement that interface. I belive you need a JDBC jar file for your database that the tutorial mentions and drop that *.jar file in under the lib folder in your project, then add the jar file to your classpath. The jar file has some class that implements that interface.

George123a at 2007-7-28 18:55:14 > top of Java-index,Java Essentials,Java Programming...
# 2

> I'm trying to run the sample code in "A Tutorial Java

> 6 New Features" by Budi Kurniawan page 167.

>

> Neither the java command line javac nor the java6

> compiler used by eclipse can find the class

> java.sql.DataSet.

Or any other compiler. There's no such class named DataSet in Java.

Sounds like you need a new book.

Why isn't the Sun JDBC tutorial sufficient?

http://java.sun.com/docs/books/tutorial/jdbc/

%

duffymoa at 2007-7-28 18:55:14 > top of Java-index,Java Essentials,Java Programming...
# 3

> I doubt anyone in the group specifically used that

> tutorial and can answer your question directly.

> However, my guess is that it cant find

> java.sql.DataSet class because its not a class that

> can be instansiated.

That's a good guessed, based on knowledge of the java.sql package, but in this case my JDK 6 javadocs don't have a DataSet class or interface. I see DataSource, but that's the closest thing I can find.

%

duffymoa at 2007-7-28 18:55:14 > top of Java-index,Java Essentials,Java Programming...
# 4

s/guess/guessed/

Might be a misprint or a misread. Time for another book. I've never heard of that one.

Could it be javax.sql.RowSet?That makes sense.

%

duffymoa at 2007-7-28 18:55:14 > top of Java-index,Java Essentials,Java Programming...
# 5

Can someone help me locate some sample JDBC 4 code that includes the import statements?

I'm specifically looking for some examples that use the annotations to specify sql queries.

I actually found some tutorials but they did not include the import statements!

Thanks,

siegfried

siega at 2007-7-28 18:55:14 > top of Java-index,Java Essentials,Java Programming...
# 6

When you type in an object such as preparedStatement within your project, your IDE should flag you that it cant find it, a good IDE such as Eclipse WTP will show a red mark next to the line, click on that and it should drop down a list of packages you can import for that preparedStatement. If its not in the list, you didn' include the JDBC jar file in your project and include it in your classpath. Example: ojdbc14.jar is a JDBC for ORacle.

George123a at 2007-7-28 18:55:14 > top of Java-index,Java Essentials,Java Programming...
# 7

> I'm specifically looking for some examples that use

> the annotations to specify sql queries.

Perhaps someone can explain to me why that would ever be a good thing.

jschella at 2007-7-28 18:55:14 > top of Java-index,Java Essentials,Java Programming...