Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v6.0
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Cobol v3.0
  HXTT DBF v6.0
  HXTT Excel v5.0
  HXTT Paradox v6.0
  HXTT Text(CSV) v6.0
  HXTT XML v2.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 Beijing City (abbr, HXTT)

HXTT ACCESS
batch insertion
Patrick K��nemann
2017-05-31 04:43:46.0
Hi,

does HXTT ACCESS support batch insertion (PreparedStatement.addBatch and PreparedStatement.executeBatch)?
Example: http://viralpatel.net/blogs/batch-insert-in-java-jdbc/

Best regards
Patrick
Re:batch insertion
HXTT Support
2017-05-31 07:53:00.0
No issue. HXTT Access supports batch insert, transaction, linked table, and so on.
Re:Re:batch insertion
Patrick K��nemann
2017-06-28 14:19:07.0
Thank you for the quick answer!
What about the option Statement.RETURN_GENERATED_KEYS in batch insertions?
I observed this for a table TEST with columns 'ID INT AUTO_INCREMENT' and 'name VARCHAR(100)':

// single insert returns auto-generated ID
final PreparedStatement stmt = connection.prepareStatement("insert into TEST (Name) values (?)", Statement.RETURN_GENERATED_KEYS);
stmt.setString(1, "x");
stmt.execute();
final ResultSet rs = stmt.getGeneratedKeys();
final List ids = new ArrayList();
while (rs.next()) {
ids.add(rs.getInt(1));
}
stmt.close();
System.out.println("Generated single ID: " + ids); // prints: [2]

// batch insert does NOT return auto-generated IDs
final PreparedStatement stmt2 = connection.prepareStatement("insert into TEST (Name) values (?)", Statement.RETURN_GENERATED_KEYS);
for (int i = 0; i < 3; i++) {
stmt2.setString(1, "x" + i);
stmt2.addBatch();
}
stmt2.executeBatch();
final ResultSet rs2 = stmt2.getGeneratedKeys();
final List ids2 = new ArrayList();
while (rs2.next()) {
ids2.add(rs2.getInt(1));
}
stmt2.close();
System.out.println("Generated batch IDs: " + ids2); // prints: []

Did I miss anything?
How is it possible to retrieve auto-generated IDs via batch insert?
Re:Re:Re:batch insertion
HXTT Support
2017-06-29 10:33:56.0
2017-06-30 PreparedStatement.executeBatch suupports RETURN_GENERATED_KEYS.

Search Key   Search by Last 50 Questions




Google
 

Email: webmaster@hxtt.com
Copyright © 1999-2017 Heng Xing Tian Tai Lab of Beijing City. | All Rights Reserved. | Privacy | Legal | Sitemap