Article View: borland.public.jbuilder.java.api
Article #17statement.executeBatch()
From: Dan Rotaru
Date: Thu, 09 Dec 2004 03:52
Date: Thu, 09 Dec 2004 03:52
33 lines
2262 bytes
2262 bytes
I tried to use statement.execteBatch with many SQL querys with a Advatage server..
I was always given the same message : 'SQL Attempt to produce a ResultSet from executeBatch'
Instead, everything is good if I use only one query.
Here is the code I used.
myStatement = POSIS.createStatement() ;
try{
if(POSIS.getMetaData().supportsBatchUpdates()){
System.out.println( "Good : Driver supports Batch Updates." );
POSIS.setAutoCommit(false) ;
try {
myStatement.clearBatch();
String sql = "Update posPrHd1 SET LINKS = 'TTTTT' where LINKS = '4M351' ";
int iCount = myStatement.executeUpdate(sql) ; // good
myStatement.addBatch(sql);
int aArray[] = myStatement.executeBatch(); // good
myStatement.addBatch(sql);
aArray = myStatement.executeBatch(); // not good
} catch( BatchUpdateException bue ){
System.err.println(bue.getMessage());
//bue.getMessage() = SQL Attempt to produce a ResultSet from executeBatch
}
POSIS.setAutoCommit(true) ;
}else {
System.err.println( "EBRun Error: Driver " + "does not support Batch Updates." );
POSIS.closeConnection();
}
}catch (Exception ee) {
System.err.println(ee.getMessage()) ;
}
POSIS.setAutoCommit(false) ;
Technical Details
Message-ID:
<41b7cbf2@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!meganewsservers.com!feeder2.on.meganewsservers.com!zen.net.uk!demorgan.zen.co.uk!194.72.9.35.MISMATCH!news-peer1!btnet-feed3!news-peer0-test!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 1089d0,5ba2eb4af83fe8a3,start X-Google-Attributes: gid1089d0,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Dan Rotaru" <danRotaru@sympatico.ca> Sender: "Dan Rotaru" <danRotaru@sympatico.ca> Reply-To: "Dan Rotaru" <danRotaru@sympatico.ca> Subject: statement.executeBatch() Newsgroups: borland.public.jbuilder.java.api X-User-Info: 70.48.97.59 NNTP-Posting-Host: 207.105.83.66 Message-ID: <41b7cbf2@newsgroups.borland.com> Date: 8 Dec 2004 19:52:18 -0800 X-Trace: newsgroups.borland.com 1102564338 207.105.83.66 (8 Dec 2004 19:52:18 -0800) Lines: 34 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!meganewsservers.com!feeder2.on.meganewsservers.com!zen.net.uk!demorgan.zen.co.uk!194.72.9.35.MISMATCH!news-peer1!btnet-feed3!news-peer0-test!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail