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.