Teradata: [Error 1154] [SQLState HY000] A failure occurred while inserting the batch of rows

不问归期 提交于 2019-12-13 02:35:38

问题


I have connected to my Teradata database via JDBC and am trying to use the FASTLOAD utility of Teradata to insert records into a table (with prepared statements and batch). Eg:

connection = DriverManager.getConnection("jdbc:teradata://192.168.1.110/TYPE=FASTLOAD", "admin", "admin");

String sql = "INSERT INTO table (RANDOM_INTEGER) VALUES (?)";
PreparedStatement preparedStatement = connection.prepareStatement(sql);

int numberOfRecordsToInsert = 100000;

        for (int i = 0; i < numberOfRecordsToInsert; i++) {

            preparedStatement.setInt(1, 5);
            preparedStatement.addBatch();

        }

preparedStatement.executeBatch();

connection.commit();    

With this (I've tried this on many different tables with different data types) I get the following error when it gets to the executeBatch() line:

Exception in thread "main" java.sql.BatchUpdateException: [Teradata JDBC Driver] [TeraJDBC 15.10.00.14] [Error 1154] [SQLState HY000] A failure occurred while inserting the batch of rows destined for database table "admin"."table". 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:148) at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeBatchUpdateException(ErrorFactory.java:132) at com.teradata.jdbc.jdbc.fastload.FastLoadManagerPreparedStatement.executeBatch(FastLoadManagerPreparedStatement.java:2202) at teradata.fastload.main(fastload.java:62) Caused by: java.sql.SQLException: [Teradata JDBC Driver] [TeraJDBC 15.10.00.14] [Error 1147] [SQLState HY000] The next failure(s) in the exception chain occurred while beginning FastLoad of database table "admin"."table" at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:94) at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:69) at com.teradata.jdbc.jdbc.fastload.FastLoadManagerPreparedStatement.beginFastLoad(FastLoadManagerPreparedStatement.java:836) at com.teradata.jdbc.jdbc.fastload.FastLoadManagerPreparedStatement.executeBatch(FastLoadManagerPreparedStatement.java:2070) ... 1 more

I don't know how to even call the getNextException that the error says.

来源:https://stackoverflow.com/questions/36449948/teradata-error-1154-sqlstate-hy000-a-failure-occurred-while-inserting-the-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!