Question

I tried to follow this example code

Everything works fine except this line

              pstmtFld.setAsciiStream(1, dataStream, -1);

It throws SQL exception .


I suspect that the sample FastLoad1.csv file that i created is not consistent with their example . However i tried to create a very simple file with exactly the same fields . Here is my FastLoad1.csv

L_INDEX,L_TIMESTAMP,L_TEXT 
1,01/01/13,testText
2,01/01/13,testText
3,01/01/13,testText
4,01/01/13,testText

Is it correct csv file . Is it consistent with the sample program ? If yes, why does it throw an exception ?


Here is the error message

 Attempting connection to Teradata with FastLoadCSV.
 Connection to Teradata with FastLoadCSV established.
 Creating a PreparedStatement object with FastLoadCSV.
 Created a PreparedStatement object with FastLoadCSV.
 Checking connection for warnings
 Streaming FastLoad1.csv
SQL State = HY000, Error Code = 1151
com.teradata.jdbc.jdbc_4.util.JDBCException: [Teradata JDBC Driver] [TeraJDBC 14.10.00.17] [Error 1151] [SQLState HY000] A failure occurred while setting a parameter value for database table "xxxxxxxxx"."my_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:93)
    at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:68)
    at com.teradata.jdbc.jdbc.fastload.FastLoadManagerPreparedStatement.setAsciiStream(FastLoadManagerPreparedStatement.java:1366)
    at T20208JD.main(T20208JD.java:160)

SQL State = HY000, Error Code = 1155
com.teradata.jdbc.jdbc_4.util.JDBCException: [Teradata JDBC Driver] [TeraJDBC 14.10.00.17] [Error 1155] [SQLState HY000] The next failure(s) in the exception chain occurred in FastLoadPreparedStatement[0] of 16 FastLoadPreparedStatement(s).
    at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:93)
    at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:73)
    at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:101)
    at com.teradata.jdbc.jdbc.fastload.FastLoadManagerPreparedStatement.setAsciiStream(FastLoadManagerPreparedStatement.java:1361)
    at T20208JD.main(T20208JD.java:160)

SQL State = HY000, Error Code = 1093
com.teradata.jdbc.jdbc_4.util.JDBCException: [Teradata JDBC Driver] [TeraJDBC 14.10.00.17] [Error 1093] [SQLState HY000] This method is not implemented
    at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:93)
    at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:63)
    at com.teradata.jdbc.jdbc.fastload.FastLoadPreparedStatement.setAsciiStream(FastLoadPreparedStatement.java:759)
    at com.teradata.jdbc.jdbc.fastload.FastLoadManagerPreparedStatement.setAsciiStream(FastLoadManagerPreparedStatement.java:1359)
    at T20208JD.main(T20208JD.java:160)


SQL State = HY000, Error Code = 1151
com.teradata.jdbc.jdbc_4.util.JDBCException: [Teradata JDBC Driver] [TeraJDBC 14.10.00.17] [Error 1151] [SQLState HY000] A failure occurred while setting a parameter value for database table "xxxxxxxx"."my_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:93)
    at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:68)
    at com.teradata.jdbc.jdbc.fastload.FastLoadManagerPreparedStatement.setAsciiStream(FastLoadManagerPreparedStatement.java:1366)
    at T20208JD.main(T20208JD.java:160)

SQL State = HY000, Error Code = 1155
com.teradata.jdbc.jdbc_4.util.JDBCException: [Teradata JDBC Driver] [TeraJDBC 14.10.00.17] [Error 1155] [SQLState HY000] The next failure(s) in the exception chain occurred in FastLoadPreparedStatement[0] of 16 FastLoadPreparedStatement(s).
    at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:93)
    at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:73)
    at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:101)
    at com.teradata.jdbc.jdbc.fastload.FastLoadManagerPreparedStatement.setAsciiStream(FastLoadManagerPreparedStatement.java:1361)
    at T20208JD.main(T20208JD.java:160)

SQL State = HY000, Error Code = 1093
com.teradata.jdbc.jdbc_4.util.JDBCException: [Teradata JDBC Driver] [TeraJDBC 14.10.00.17] [Error 1093] [SQLState HY000] This method is not implemented
    at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:93)
    at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:63)
    at com.teradata.jdbc.jdbc.fastload.FastLoadPreparedStatement.setAsciiStream(FastLoadPreparedStatement.java:759)
    at com.teradata.jdbc.jdbc.fastload.FastLoadManagerPreparedStatement.setAsciiStream(FastLoadManagerPreparedStatement.java:1359)
    at T20208JD.main(T20208JD.java:160)

Exception in thread "main" java.lang.IllegalStateException: Sample failed.
    at T20208JD.main(T20208JD.java:336)
Was it helpful?

Solution 2

L_TIMESTAMP is supposed to be a timestamp, but it's a date in the CSV. And it's probably not in the correct format. Do a SHOW TABLE and check the FORMAT, then modify your data accordingly or add it to your INSERT:

VALUES(?,? (TIMESTAMP, FORMAT 'mm/dd/yy'),?)

And when you use a two-digit year you might not get the expected century (based on some dbscontrol settings)

OTHER TIPS

Yes, this is correct csv file. But, if you want generate dummy data in csv format, Here is a link http://dummydata.me/ Might be useful for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top