Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v7.1
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Cobol v5.0
  HXTT DBF v7.1
  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)

HXTT ACCESS
batch insertion
Patrick K��nemann
2017-05-31 04:43:46
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
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
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
2017-06-30 PreparedStatement.executeBatch suupports RETURN_GENERATED_KEYS.

Search Key   Search by Last 50 Questions




Google
 

Email: webmaster@hxtt.com
Copyright © 2003-2019 Heng Xing Tian Tai Lab of Xi'an City. | All Rights Reserved. | Privacy | Legal | Refund | Sitemap