我尝试按照example code
进行操作除了这一行
之外,一切正常 pstmtFld.setAsciiStream(1, dataStream, -1);
抛出SQL异常。
我怀疑我创建的示例FastLoad1.csv
文件与他们的示例不一致。但是我试图用完全相同的字段创建一个非常简单的文件。这是我的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
csv文件是否正确。它与示例程序一致吗?如果是,为什么会抛出异常?
以下是错误消息
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)
答案 0 :(得分:7)
是的,这是正确的csv文件。 但是,如果要生成csv格式的伪数据, 这是一个链接http://dummydata.me/ 可能对你有用。
答案 1 :(得分:5)
L_TIMESTAMP应该是一个时间戳,但它是CSV中的日期。它可能不是正确的格式。执行SHOW TABLE并检查FORMAT,然后相应地修改数据或将其添加到INSERT:
VALUES(?,? (TIMESTAMP, FORMAT 'mm/dd/yy'),?)
当你使用两位数的年份时,你可能无法获得预期的世纪(基于一些dbscontrol设置)