FASTLOADCSV Error JAVA

Database
Enthusiast

FASTLOADCSV Error JAVA

Hi Everybody, 

I  am having problem on using the FastLoad protocol. I am tryng to insert data, based on a csv file,  into a Teradata (V.14) table using the JDBC Teradata driver. Here it is my URL connection:

jdbc:teradata://XXX.XXX.XXX.XXX/DATABASE=XXX_XXX_XXX,TMODE=ANSI,CHARSET=UTF8,TYPE=FASTLOADCSV 

and here it is (in a simple way) my code:

        
String query = "INSERT INTO MY_TABLE VALUES (?,?,?,?,?,?,?,?,?)";
Connection c = DriverManager.getConnection(getUrl(), getUser(), getPasswd());

// The error accur right here when I am tring to get the PreparedStatement from Connection.
PreparedStatement pstmt = con.prepareStatement(query);
//It doesnt get at this point =(

pstmt.setAsciiStream(1, inStream, -1);
pstmt.executeUpdate();

Here it is the error:

java.sql.SQLException: [Teradata JDBC Driver] [TeraJDBC 15.10.00.05] [Error 1383] [SQLState HY000] The next failure(s) in the exception chain occurred while creating FastLoad resources for destination database table. Found 86 AMP(s) and created 0 Connection(s) and 0 PreparedStatement(s) with SESSIONS=0, but all FastLoad resources that were created have now been closed.
at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:94)
at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:84)
at com.teradata.jdbc.jdbc.fastload.FastLoadCSVPreparedStatement.connectFastLoad(FastLoadCSVPreparedStatement.java:435)
at com.teradata.jdbc.jdbc.fastload.FastLoadCSVPreparedStatement.initializeFastLoad(FastLoadCSVPreparedStatement.java:272)
at com.teradata.jdbc.jdbc.fastload.FastLoadCSVPreparedStatement.<init>(FastLoadCSVPreparedStatement.java:233)
at com.teradata.jdbc.jdk6.JDK6_FastLoadCSV_PreparedStatement.<init>(JDK6_FastLoadCSV_PreparedStatement.java:22)
at com.teradata.jdbc.jdk6.JDK6_FastLoadCSV_Connection.constructPreparedStatement(JDK6_FastLoadCSV_Connection.java:30)
at com.teradata.jdbc.jdbc.fastload.FastLoadCSVConnection.prepareStatement(FastLoadCSVConnection.java:356)
at CSVLoader.fastLoad(CSVLoader.java:130)
at Persistence.fastLoad(Persistence.java:132)
at CMain.run(CMain.java:65)
at CMain.main(CMain.java:43)

Thanks for yout time.

3 REPLIES
Teradata Employee

Re: FASTLOADCSV Error JAVA

Your program needs to iterate through and print the entire SQLException chain, by calling getNextException. Please refer to our JDBC FastLoad sample programs for how to do this. All JDBC sample programs are available here on Developer Exchange.

http://developer.teradata.com/doc/connectivity/jdbc/reference/current/samplePrograms.html

Enthusiast

Re: FASTLOADCSV Error JAVA

Hi Tom, 

I have executed the source T20208JD.java and I think you may see the complete error track here:

Sample T20208JD starting: Tue Aug 04 10:13:21 ART 2015
Looking for the Teradata JDBC driver.
Teradata JDBC driver loaded.
Attempting connection to Teradata.
Connection to Teradata established.
Creating a Statement object.
Created a Statement object.
Drop table exception ignored: java.sql.SQLException: [Teradata Database] [TeraJDBC 15.10.00.05] [Error 3807] [SQLState 42S02] Object 'DB.T20208JD_ERR_1' does not exist.
Drop table exception ignored: java.sql.SQLException: [Teradata Database] [TeraJDBC 15.10.00.05] [Error 3807] [SQLState 42S02] Object 'DB.T20208JD_ERR_2' does not exist.
Creating table DB.T20208JD.
Created table DB.T20208JD.
Opening C:\Users\myuser\Documents\query_result\query_result.csv
Attempting connection to Teradata with FastLoadCSV.
Connection to Teradata with FastLoadCSV established.
Creating a PreparedStatement object with FastLoadCSV.
SQL State = HY000, Error Code = 1384
java.sql.SQLException: [Teradata JDBC Driver] [TeraJDBC 15.10.00.05] [Error 1384] [SQLState HY000] A failure occurred while initializing FastLoad resources for destination database 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.makeDriverJDBCException(ErrorFactory.java:94)
at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:64)
at com.teradata.jdbc.jdbc.fastload.FastLoadCSVPreparedStatement.initializeFastLoad(FastLoadCSVPreparedStatement.java:276)
at com.teradata.jdbc.jdbc.fastload.FastLoadCSVPreparedStatement.<init>(FastLoadCSVPreparedStatement.java:233)
at com.teradata.jdbc.jdk6.JDK6_FastLoadCSV_PreparedStatement.<init>(JDK6_FastLoadCSV_PreparedStatement.java:22)
at com.teradata.jdbc.jdk6.JDK6_FastLoadCSV_Connection.constructPreparedStatement(JDK6_FastLoadCSV_Connection.java:30)
at com.teradata.jdbc.jdbc.fastload.FastLoadCSVConnection.prepareStatement(FastLoadCSVConnection.java:356)
at T20208JD.main(T20208JD.java:159)

SQL State = HY000, Error Code = 1383
java.sql.SQLException: [Teradata JDBC Driver] [TeraJDBC 15.10.00.05] [Error 1383] [SQLState HY000] The next failure(s) in the exception chain occurred while creating FastLoad resources for destination database table. Found 86 AMP(s) and created 4 Connection(s) and 0 PreparedStatement(s) with SESSIONS=0, but all FastLoad resources that were created have now been closed.
at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:94)
at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:84)
at com.teradata.jdbc.jdbc.fastload.FastLoadCSVPreparedStatement.connectFastLoad(FastLoadCSVPreparedStatement.java:435)
at com.teradata.jdbc.jdbc.fastload.FastLoadCSVPreparedStatement.initializeFastLoad(FastLoadCSVPreparedStatement.java:272)
at com.teradata.jdbc.jdbc.fastload.FastLoadCSVPreparedStatement.<init>(FastLoadCSVPreparedStatement.java:233)
at com.teradata.jdbc.jdk6.JDK6_FastLoadCSV_PreparedStatement.<init>(JDK6_FastLoadCSV_PreparedStatement.java:22)
at com.teradata.jdbc.jdk6.JDK6_FastLoadCSV_Connection.constructPreparedStatement(JDK6_FastLoadCSV_Connection.java:30)
at com.teradata.jdbc.jdbc.fastload.FastLoadCSVConnection.prepareStatement(FastLoadCSVConnection.java:356)
at T20208JD.main(T20208JD.java:159)

SQL State = HY000, Error Code = 2632
java.sql.SQLException: [Teradata Database] [TeraJDBC 15.10.00.05] [Error 2632] [SQLState HY000] All AMPs own sessions for this Fast/Multi Load or FastExport.
at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDatabaseSQLException(ErrorFactory.java:301)
at com.teradata.jdbc.jdbc.GenericLogonController.run(GenericLogonController.java:659)
at com.teradata.jdbc.jdbc.raw.RawConnection.<init>(RawConnection.java:68)
at com.teradata.jdbc.jdk6.JDK6_Raw_Connection.<init>(JDK6_Raw_Connection.java:28)
at com.teradata.jdbc.jdk6.JDK6ConnectionFactory.constructRawConnection(JDK6ConnectionFactory.java:73)
at com.teradata.jdbc.jdbc.ConnectionFactory.createConnection(ConnectionFactory.java:214)
at com.teradata.jdbc.jdbc.ConnectionFactory.createConnection(ConnectionFactory.java:169)
at com.teradata.jdbc.jdbc.fastload.FastLoadCSVPreparedStatement.connectFastLoad(FastLoadCSVPreparedStatement.java:375)
at com.teradata.jdbc.jdbc.fastload.FastLoadCSVPreparedStatement.initializeFastLoad(FastLoadCSVPreparedStatement.java:272)
at com.teradata.jdbc.jdbc.fastload.FastLoadCSVPreparedStatement.<init>(FastLoadCSVPreparedStatement.java:233)
at com.teradata.jdbc.jdk6.JDK6_FastLoadCSV_PreparedStatement.<init>(JDK6_FastLoadCSV_PreparedStatement.java:22)
at com.teradata.jdbc.jdk6.JDK6_FastLoadCSV_Connection.constructPreparedStatement(JDK6_FastLoadCSV_Connection.java:30)
at com.teradata.jdbc.jdbc.fastload.FastLoadCSVConnection.prepareStatement(FastLoadCSVConnection.java:356)
at T20208JD.main(T20208JD.java:159)

Closing Connection to Teradata with FastLoadCSV.
Connection to Teradata with FastLoadCSV closed.
Closing C:\Users\myuser\Documents\query_result\query_result.csv
Closing Statement object.
Statement object closed.
Closing Connection to Teradata.

Any idea?

thanks

Teradata Employee

Re: FASTLOADCSV Error JAVA

Error 2632 is a Teradata Database error ("All AMPs own sessions for this Fast/Multi Load or FastExport.")

The Teradata Database Messages book says the following:

Explanation: This error occurs when all AMPs have a session assigned to them for the ongoing FastLoad, MLoad or FastExport.

Notes: This error exists only to instruct the utility program to stop attempting to log sessions onto the Teradata DBS.

This error does not normally occur, because the Teradata JDBC Driver includes logic to avoid logging on too many FastLoad or FastExport data sessions.

There must be something unusual with your Teradata Database configuration that would permit this error to occur.

As a workaround, you should be able to avoid this error by specifying the SESSIONS= connection parameter.

Specify a small number of sessions, such as SESSIONS=1 or SESSIONS=2, and see if you avoid this error.

If you are a customer, please feel free to open a Teradata customer service incident so we can troubleshoot this issue further.