RE: Implicit conversion from data type text to nvarchar is not allowed.
- From: mweber@xxxxxxxxxxxxxxxxxxxxx (Matt Weber [MSFT])
- Date: Sat, 19 Aug 2006 01:55:42 GMT
Hello Bo,
This is a known issue when using the SQL Server 2005 JDBC Driver to access
SQL Server 2000. The following section from the release.txt file applies:
========================================================================
3) SQL SERVER 2000 DATA CONVERSION LIMITATIONS
When using SQL Server 2000 with the JDBC driver, the following data
conversion limitations apply:
- String data cannot be converted to an underlying money or
smallmoney column.
- String data longer than 4000 characters cannot be converted
to char or varchar underlying columns.
- String data more than 4000 characters cannot be converted to nchar or
nvarchar underlying columns if the sendStringParametersAsUnicode
connection string property is set to false, or the setAsciiStream
method is called.
- String data cannot be converted to text columns if the
sendStringParametersAsUnicode connection string property is set
to true. If you need to support string to text columns conversions,
set the sendStringParametersAsUnicode property to false.
========================================================================
The following test on my system is resolved by setting
sendStringParametersAsUnicode to false:
Connection conn = null;
conn = DriverManager.getConnection(connStr);
if (null == conn) {
System.out.println("Unable to establish connection.");
return;
}
PreparedStatement ps = conn.prepareStatement("INSERT INTO StringInput
VALUES (?)");
String myString = "The quick brown fox jumps over the lazy dog.";
ps.setAsciiStream(1, new ByteArrayInputStream(myString.getBytes()),
myString.length());
int updateCount = ps.executeUpdate();
ps.close();
conn.close();
Incidentally, I am not familiar with any indexing issues that arise from
the use of setString() that would be alleviated by using setAsciiStream().
Both methods actually appear the same when viewed from the server:
declare @P1 int
set @P1=1
exec sp_prepexec @P1 output, N'@P0 varchar(8000)', N'INSERT INTO
StringInput VALUES (@P0) ', 'The quick brown fox jumps over the lazy
dog.'
select @P1
Best regards,
Matt
--
Matt Weber [MSFT]
Microsoft Developer Support - SQL Developer
This posting is provided "AS IS", with no warranties, and confers no rights.
Please do not send email directly to this alias. This alias is for
newsgroup purposes only.
.
- Follow-Ups:
- References:
- Prev by Date: Re: MS SQL Server 2005 JDBC Driver Performance Issue
- Next by Date: Re: Implicit conversion from data type text to nvarchar is not allowed.
- Previous by thread: Implicit conversion from data type text to nvarchar is not allowed.
- Next by thread: Re: Implicit conversion from data type text to nvarchar is not allowed.
- Index(es):
Relevant Pages
|