FastLoad from Java


FastLoad from Java


I want to connect a Java application to a Teradata DB (via JDBC) and insert about one million records in a table, but I need the fastest way to do it.

I've tried to insert using the executeUpdate method of the PreparedStatement interface, but the insert ratio was 20 records per second.

The last JDBC driver includes a package with the classes that make possible to execute FastLoad from Java which would be the solution I need.

The problem is that there is no documentation for this way of insertion from a Java application (at least, I couldn't find it) and I want to know how to do it.

I've tried this code, but I've got an error:

TeraDriver tdDriver = (TeraDriver)Class.forName("com.ncr.teradata.TeraDriver").newInstance();
//With the PARTITION parameter I specify I'll use FastLoad and the DriverManager will return a FastLoadConnection
Connection con = DriverManager.getConnection("jdbc:teradata://servername/PARTITION=FASTLOAD", "user", "pwd");
//The FastLoadConnection will return a FastLoadPreparedStatement
PreparedStatement stmt = con.prepareStatement(
"FIELD1, " +
"FIELD2, " +
"FIELD3, " +
"FIELD4" +
") " +
"VALUES (?, ?, ?, ?)");
//Iterates over a collection
while(it.hasNext()) {
o =;

stmt.setString(1, o.getField1());
stmt.setString(2, o.getField2());
stmt.setDouble(3, o.getField3());
stmt.setDate(4, new Date(o.getField4().getTime()));

//Finally, I execute FastLoad
int [] numInserts = stmt.executeBatch();

The executeBath throws an Exception:
[NCR] [Teradata DBMS] : The DBS restarted between FastLoad or MLoad requests.

Please help!

Thanks a lot.

PD: Sorry for my English
Teradata Employee

Re: FastLoad from Java

Information about how to use JDBC FastLoad is available in the Teradata JDBC Driver Reference.

You must specify the connection parameter TYPE=FASTLOAD, not PARTITION=FASTLOAD.