All Forums Database
benjamin_wang 4 posts Joined 07/11
17 Jan 2012
Faled to invoke PreparedStatement executeUpdate method

My program is very simple, jsut one thread.  But exception was raised each time ran,

java.sql.BatchUpdateException: [Teradata JDBC Driver] [TeraJDBC 13.00.00.25] [Error 1338] [SQLState HY000] A failure occurred while executing a PreparedStatement batch request. Details of the failure can be found in the exception chain that is accessible with getNextException.
        at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeBatchUp dateException(ErrorFactory.java:146)
        at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeBatchUp dateException(ErrorFactory.java:135)
        at com.teradata.jdbc.jdbc_4.PreparedStatement.executeBatc hDMLArray(PreparedStatement.java:172)
        at com.teradata.jdbc.jdbc_3.ifjdbc_4.TeraLocalPreparedSta tement.executeBatch(TeraLocalPreparedStatement.java: 276)

 

The source code is as below,

 

mConnection.setAutoCommit(false);
mPreparedStatement = mConnection.prepareStatement(sql);
result = true;

int nCount = 0;
try
{
  if ( null != rs )  //rs is the resultSet from other database
  {
      while( rs.next() )
      {
          nCount++;
          //dbInst.clearParameters();
          prepareParameters(rs, syncTbl, dbInst);
          dbInst.addBatch();
         
          if (nCount % 100  == 0)
          {
              nCount = 0;
              dbInst.executePreparedBatch();
          }
      }
     
      if (nCount > 0)
          dbInst.executePreparedBatch();
  }
 
  dbInst.Commit();
}
catch(Exception e)
{
   ....
}

 

Thanks in advance

tomnolan 594 posts Joined 01/08
17 Jan 2012

Teradata JDBC Driver version 13.00.00.25 is a rather old version. You should consider upgrading to a newer version.

You should modify your application to walk the SQLException chain using the SQLException.getNextException method.

catch (SQLException ex)
{
    for ( ; ex != null ; ex = ex.getNextException ())
        ex.printStackTrace () ;
}
siddha.sumit 3 posts Joined 10/15
15 Oct 2015

Hello,
I am using [Teradata JDBC Driver] [TeraJDBC 14.00.00.41] and getting below exception chain :

Exception Occured::java.sql.BatchUpdateException: 

[Teradata JDBC Driver] [TeraJDBC 14.00.00.41] 

[Error 1338] [SQLState HY000] A failure occurred while executing a PreparedStatement batch request. Details of the failure can be found in the exception chain that is accessible with getNextException.

 

ent.java:2358)[com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeBatchUpdateException(ErrorFactory.java:147), com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeBatchUpdateException(ErrorFactory.java:136), 

com.teradata.jdbc.jdbc_4.TDPreparedStatement.executeBatchDMLArray

(TDPreparedStatement.java:254), com.teradata.jdbc.jdbc_4.TDPreparedStatement.executeBatch(TDPreparedStatem, sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

 

Any idea about above problem.

 

Thanks,

SJ

SJ

tomnolan 594 posts Joined 01/08
15 Oct 2015

Sumit, this is a duplicate post, and you should have posted this question as a new forum thread. Please do not "necro" old threads from 3 years ago.
 
The Teradata JDBC Driver User Guide documents how an application should handle a BatchUpdateException. Here is a link to the relevant section in the documentation:
http://developer.teradata.com/doc/connectivity/jdbc/reference/current/jdbcug_chapter_2.html#CCHJHFDI

You must sign in to leave a comment.