for(i=0;i< queries.lenght;i++)
stmt.addBatch(queries[i])
try
{
stmt.BatchExecute();
}
catch(SQLException e)
{
e.printStackTrace();
}
Main Topics
Browse All TopicsHi
I am tryning to batch execute a query set of 99000. But when i execute these as batch , it throws an exception after 4000 queries saying comma not found and dont execute rest of the queries.
I want that my rest of the queries should be executed. How to do it. All the falied queries should be listed in my logger but these should not stop from executing other queries..
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Well, that's not really handling it at all ;-) You need to commit the ones that were successful. Something like
http://www.exampledepot.co
insert into table(column1, column2, column3) values('val1','val2','val3
all queries are insert queries
Let me brief about history.
I have to write a utility to migrate data from logs to database table. Values in logs are comma separated. I m reading them and creating list of queries.
and than i am trying to insert them in database using batch update.
but it seems some of the values from logs were not read well and therefore creating sytax error.
But expect those queries, i want to insert all othr in database.
i m not using prepared statement.
also can you pls explain how to create and execute script instead of jdbc.
CRHJ,
Sorry,I cant attach log bcs these are prod logs. but i can give u sample format
==========================
12/31.2009, http://google.com, 123, ,
12/31.2009, http://google.com, 123, , 515
12/31.2009, http://google.com, 123, ,
12/31.2009, http://google.com, 123, , 515
==========================
public void performBatch(Connection conn, List queries) throws SQLException
{
String query;
Statement stmt;
try {
conn.setAutoCommit(false);
stmt = conn.createStatement();
for (int i = 0; i < queries.size(); i++)
{
stmt.addBatch((String)quer
}
// Execute the batch
// int [] updateCounts = stmt.executeBatch();
// Since there were no errors, commit
conn.commit();
}
catch (BatchUpdateException e)
{
// Not all of the statements were successfully executed
int[] updateCounts = e.getUpdateCounts();
// Some databases will continue to execute after one fails.
// If so, updateCounts.length will equal the number of batched statements.
// If not, updateCounts.length will equal the number of successfully executed statements
processUpdateCounts(update
// Either commit the successfully executed statements or rollback the entire batch
conn.rollback();
}
catch (SQLException e)
{
System.out.println("Query Falied to execute:" + (String)queries.get(i));
}
finally
{
conn.commit();
}
}
You need to see the comment i made at http:#24776270 - you're not doing that - in fact you're doing the opposite
Business Accounts
Answer for Membership
by: CEHJPosted on 2009-07-04 at 00:00:55ID: 24776120
You need to handle BatchUpdateException properly - how are you doing that currently?