Faled to invoke PreparedStatement executeUpdate method

Database

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.makeBatchUpdateException(ErrorFactory.java:146)

        at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeBatchUpdateException(ErrorFactory.java:135)

        at com.teradata.jdbc.jdbc_4.PreparedStatement.executeBatchDMLArray(PreparedStatement.java:172)

        at com.teradata.jdbc.jdbc_3.ifjdbc_4.TeraLocalPreparedStatement.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

3 REPLIES
Teradata Employee

Re: Faled to invoke PreparedStatement executeUpdate method

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 () ;
}

Re: Faled to invoke PreparedStatement executeUpdate method

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

Teradata Employee

Re: Faled to invoke PreparedStatement executeUpdate method

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