java 1.4 :how to insert multiple records in a database with one single hit using executeBatch?

1.5k views Asked by At

i am reading records data from a file(records count can be up to thousands ).Now i want to insert each record in to database.I want to insert all of records in one hit to reduce performance hit. If i use addBatch(String sqlQuery ) on statment object,my sql query should be static .but in my case query will be non static.Please tell me possible solutions with best performance?

platform java 1.4 sql server 2000.

1

There are 1 answers

2
o.k.w On BEST ANSWER

From Wiki

A SQL feature (since SQL-92) is the use of row value constructors to insert multiple rows at a time in a single SQL statement:

INSERT INTO ''TABLE'' (''column1'', [''column2, ... '']) 
VALUES (''value1a'', [''value1b, ...'']), 
       (''value2a'', [''value2b, ...'']), 
   ...