2012-09-07 28 views
0

我們遇到了JTDS文檔中有關索引掃描(SQL Server 2000及更高版本)中描述的性能問題,因此必須將sendStringParametersAsUnicode參數設置爲falseJTDS:Unicode參數使用CallableStatement with sendStringParametersAsUnicode = false

這對99.9%的情況很好,但是,我們有一個應用程序在ntext字段中依賴unicode數據。我們使用具有NTEXT參數的存儲過程寫入上述表。由於更改了上述設置,我們的Unicode字符串被轉換爲'?'字符,這不是特別有用。

我已經擺弄各種事情,包括:

  • setObject(1, unicode_string, Types.NCLOB); //as well as NVARCHAR

  • stmt.setUnicodeStream(1, new ByteArrayInputStream(unicode_string.getBytes("UTF16")), unicode_string.length());

  • setNClob(1, unicode_string);

這些都不但工作。有任何想法嗎?

回答

0

一種解決方法(雖然它不是正確答案),是使用聲明而非CallableStatement的

stmt = cn.createStatement(); 
stmt.execute("INSERT INTO test_unicode (my_unicode) VALUES (N'" + input + "')"); 

但是,這是提出了一個顯著的性能開銷。

相關問題