Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v5.2
  HXTT Cobol v2.1
  HXTT DBF v5.2
  Buy Now
  HXTT Excel v4.2
  HXTT Paradox v5.2
  HXTT Text(CSV) v5.2
  HXTT XML v1.2
Offshore Outsourcing
Oracle Data Import/Export
DB2 Data Import/Export
Sybase Data Import/Export
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
Hongxin Technology & Trade Ltd. of Xiangtan City (abbr, HXTT)

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

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.0
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.0

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.0
>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.0
I see, HXTT DBF supports both sequences and auto-increment columns! Thanks for clarifying it!

Jan Dvorak

Search Key   Search by Last 50 Questions


Address: 9 Station Rd., Xiangtan City, Hunan Province, P.R. China
Postcode: 411100
Phone: (86)731-58225727
Fax: (86)731-58225727
Copyright © 1999-2011 Hongxin Technology & Trade Ltd. | All Rights Reserved. | Privacy | Legal | Sitemap