-
Sep 22nd, 2010, 11:39 PM
#1
simplejdbc template batch update is not working
Hi All,
I am using simplejdbctemplate to insert the batchupdate in the following code
public void importData(final HashMap map)
{
if(map.size()>0)
{
setIdentityInsert((String)map.get("TableName"),"ON ");
try
{
int[] updateCounts = template.batchUpdate((String) map.get("Query"), (List<Object[]>)map.get("Values"), (int[])map.get("Sqltypes"));
} catch (Exception ex)
{
ex.printStackTrace();
}
setIdentityInsert((String)map.get("TableName"),"OF F");
}
}
bur i am getting the following exception
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [insert into TURBINE_GROUP(GROUP_NAME,OBJECTDATA) values(?,?)]; nested exception is java.sql.SQLException: Invalid parameter index 3.
at org.springframework.jdbc.support.SQLStateSQLExcept ionTranslator.doTranslate(SQLStateSQLExceptionTran slator.java:98)
at org.springframework.jdbc.support.AbstractFallbackS QLExceptionTranslator.translate(AbstractFallbackSQ LExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackS QLExceptionTranslator.translate(AbstractFallbackSQ LExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackS QLExceptionTranslator.translate(AbstractFallbackSQ LExceptionTranslator.java:80)
at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:602)
at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:614)
at org.springframework.jdbc.core.JdbcTemplate.batchUp date(JdbcTemplate.java:883)
at org.springframework.jdbc.core.BatchUpdateUtils.exe cuteBatchUpdate(BatchUpdateUtils.java:32)
at org.springframework.jdbc.core.simple.SimpleJdbcTem plate.batchUpdate(SimpleJdbcTemplate.java:257)
at com.intervoice.cc.tools.dbexport.DBExportImpl.impo rtData(DBExportImpl.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:183)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :150)
at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:110)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :172)
at org.springframework.aop.interceptor.ExposeInvocati onInterceptor.invoke(ExposeInvocationInterceptor.j ava:89)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :172)
at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy4.importData(Unknown Source)
at com.intervoice.cc.tools.dbexport.util.SQLUtil.dbim port(SQLUtil.java:186)
at com.intervoice.cc.tools.dbexport.Main.importData(M ain.java:126)
at com.intervoice.cc.tools.dbexport.Main.main(Main.ja va:61)
Caused by: java.sql.SQLException: Invalid parameter index 3.
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.ge tParameter(JtdsPreparedStatement.java:340)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.se tParameter(JtdsPreparedStatement.java:409)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.se tObjectBase(JtdsPreparedStatement.java:395)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.se tObject(JtdsPreparedStatement.java:672)
at org.apache.commons.dbcp.DelegatingPreparedStatemen t.setObject(DelegatingPreparedStatement.java:162)
at org.springframework.jdbc.core.StatementCreatorUtil s.setValue(StatementCreatorUtils.java:356)
at org.springframework.jdbc.core.StatementCreatorUtil s.setParameterValueInternal(StatementCreatorUtils. java:216)
at org.springframework.jdbc.core.StatementCreatorUtil s.setParameterValue(StatementCreatorUtils.java:144 )
at org.springframework.jdbc.core.BatchUpdateUtils.set StatementParameters(BatchUpdateUtils.java:63)
at org.springframework.jdbc.core.BatchUpdateUtils$1.s etValues(BatchUpdateUtils.java:38)
at org.springframework.jdbc.core.JdbcTemplate$4.doInP reparedStatement(JdbcTemplate.java:892)
at org.springframework.jdbc.core.JdbcTemplate$4.doInP reparedStatement(JdbcTemplate.java:1)
at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:586)
... 21 more
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules