2014-03-07 37 views
3

我從official teradata website測試fastload示例代碼。過於謹慎的一面,我使用位於其samples.jar here如何ascii流綁定到一個事先準備好的聲明

當我運行此示例代碼,我在這條線得到一個錯誤的樣本FastLoad1.csv

pstmtFld.setAsciiStream(1, dataStream, -1); // This method is not implemented 

必須如何調用setAsciiStream可與使用準備好聲明?

難道我正確地使用setAsciiStream


這裏是控制檯

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

是jdbc足夠聰明,在這種情況下打開,消耗,關閉每個流3次? – Leo

+0

什麼是表格模式? –

+0

表是完全一樣的示例程序http://developer.teradata.com/doc/connectivity/jdbc/reference/current/samp/T20208JD.java.txt我創建了一個FastLoad1.csv文件方含三個變量完全按照示例程序 – Buras

回答

8

我試圖編譯示例T20208JD,剛剛修改DNS /用戶/密碼,它在我的Mac平穩運行。所以pstmtFld.setAsciiStream(1,dataStream,-1);似乎是正確的。

我用JDBC 14.10.00.18,你可以嘗試從Teradata的開發者交流下載最新版本14.10.00.26:http://downloads.teradata.com/download/connectivity/jdbc-driver

我不認爲這將解決這個問題,但是......

+0

+1謝謝我更新了jdbc,但沒有結果。你在用嗎?我的是'String urlFld =「jdbc:teradata:// XXX/LOGMECH = LDAP,tmode = ANSI,charset = UTF8,LOGDATA ='authcid = userid password = mypassword',TYPE = FASTLOAD」; ' ' – Buras

+0

它是否與連接字符串不同 – Buras

+0

我使用了示例中的一個,只是修改了用戶名和密碼:「jdbc:teradata:// xxx/TMODE = ANSI,CHARSET = UTF8,TYPE = FASTLOADCSV」。這與你的不同,TYPE = FASTLOAD vs. TYPE = FASTLOADCSV – dnoeth

1

錯誤消息,我認爲錯誤是由-1,第三個參數,它告訴調用setAsciiStream的字節流具有-1字節造成的。

當我在過去使用setAsciiStream()時,如果超過254個字符,我使用了bufferInputStreamString的大小。

String convRule; 
    ... 
    if (convRule.length() > 254) { 
     int size = convRule.length(); 
     BufferedInputStream bais = new BufferedInputStream(new ByteArrayInputStream(convRule.getBytes())); 
     pStmt.setAsciiStream(4, bais, size); 
    } 

所以,比較雷到你,我可以告訴第三個參數是不同的應該是輸入流的length

+0

+1感謝。什麼是convRule?它從何而來? – Buras

+0

@ Buras對不起,'convRule'只是一個'String',我剛從一些舊代碼中複製了這段代碼,我用'setAsciiStream'。 –

相關問題