2014-03-07 66 views
2

我試圖按照這種example code示例FastLoad1.csv文件應該如何顯示?

一切工作正常,除了這行

   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) 

回答

5

L_TIMESTAMP應該是一個時間戳,但它是CSV中的一個日期。它可能不是正確的格式。做一個節目表和檢查格式,然後相應地修改您的數據或將其添加到您的INSERT:

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

而當你使用一個兩位數的年份,你可能無法得到預期的世紀(基於一些dbscontrol設置)

+0

謝謝我改變了它,甚至修改爲一個普通的VARCHAR,但仍然有'setAsciiStream'同樣的錯誤 – Buras

+0

返回哪個錯誤?你爲什麼不嘗試使用samples.jar中的FastLoad1.csv?該文件中的數據看起來像1,2010-08-11 13:19:05.1,一些文本 – dnoeth

+0

謝謝,我沒有注意到該文件。我嘗試過使用它,但得到了相同的異常 – Buras

7

是的,這是正確的CSV文件。 但是,如果你想生成csv格式的虛擬數據, 這裏是一個鏈接http://dummydata.me/ 可能對你有用。

+0

+1好人員thatnks – Buras