Hello,
I when I attempt to create a sequence in a clear database directory,
all I get is a NullPointerException.
I tried both v.2.2 and v.2.1 of HXTT DBF JDBC 3.0.
I'm using Sun Java 1.5.0_06, Windows XP SP2.
What am I doing wrong?
Jan Dvorak
MathAn Praha
File tmp = File.createTempFile( "hxttdbf-", "-test" );
tmp.delete();
tmp.mkdir();
Class.forName("com.hxtt.sql.dbf.DBFDriver");
String url = "jdbc:dbf:///" + tmp.getAbsolutePath();
Connection c = DriverManager.getConnection(url);
Statement s = c.createStatement();
s.execute( "CREATE SEQUENCE the_sequence" );
|
Recurred and fixed a bug which doesn't think all options will be omited. Please download the latest package.
|
Hello,
When I do
connection.prepareStatement( "INSERT INTO mytable( id, x ) VALUES ( NEXTVAL('the_sequence'), ? )", Statement.RETURN_GENERATED_KEYS );
bind the first parameter to a suitable value, and executeUpdate() on the returned statement, I still can't retrieve the autogenerated key. What happens is that the ResultSet I obtain from getGeneratedKeys() is empty. Is that correct?
Or is there any other way to retrieve the autogenerated key? I wouldn't hesitate issuing a SELECT CURRVAL('the_sequence') FROM ..., if only there was a suitable one-row table. (Oracle has the DUAL table which has already saved me from great trouble a couple times.)
Jan Dvorak
P.S. Thanks for the fast response to the problem with creating a sequence. It works for me now.
|
>Is that correct
Yeah. getGeneratedKeys() will return values if id is an autoincrement column.
>SELECT CURRVAL('the_sequence') FROM ...
You should use "?currval('the_sequence') . Of course, "SELECT top 1 CURRVAL('the_sequence') FROM mytable" can work but DUAL table isn't supported now.
|
I see, HXTT DBF supports both sequences and auto-increment columns! Thanks for clarifying it!
Jan Dvorak
|