Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v7.1
  HXTT Cobol v5.0
  HXTT DBF v7.1
  Buy Now
  HXTT Excel v6.1
  HXTT Json v1.0
  HXTT Paradox v7.1
  HXTT PDF v2.0
  HXTT Text(CSV) v7.1
  HXTT Word v1.1
  HXTT XML v4.0
Offshore Outsourcing
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
Heng Xing Tian Tai Lab of Xi'an City (abbr, HXTT)

Trouble creating a sequence
Jan Dvorak
2006-03-16 00:00:00

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" );
String url = "jdbc:dbf:///" + tmp.getAbsolutePath();
Connection c = DriverManager.getConnection(url);
Statement s = c.createStatement();
s.execute( "CREATE SEQUENCE the_sequence" );
Re:Trouble creating a sequence
HXTT Support
2006-03-16 00:00:00
Recurred and fixed a bug which doesn't think all options will be omited. Please download the latest package.
Getting the autogenerated key
Jan Dvorak
2006-03-16 00:00:00

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.
Re:Re:Re:Trouble creating a sequence
HXTT Support
2006-03-16 00:00:00
>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.
Re: Getting the autogenerated key
Jan Dvorak
2006-03-17 00:00:00
I see, HXTT DBF supports both sequences and auto-increment columns! Thanks for clarifying it!

Jan Dvorak

Search Key   Search by Last 50 Questions


Copyright © 2003-2019 Heng Xing Tian Tai Lab of Xi'an City. | All Rights Reserved. | Privacy | Legal | Sitemap