Re: Implicit conversion from data type text to nvarchar is not allowed.
- From: Bo Zhu <ffkiller@xxxxxxxxxxxxxxxxx>
- Date: Mon, 21 Aug 2006 14:15:33 +0800
Hi Matt,
Thanks for your response.
The data conversion known issue you mentioned doesn't seem to apply in this case because I am converting String data less than 4000 characters to varchar column with setAsciiStream().
By setting sendStringParametersAsUnicode property to false, I no longer get any SQLException. But in a complex server environment, I am not sure whether I can set that property without impacting other modules.
Personally I've no experience with indexing issues arising from setString() method, probably I'll do some testing to see what happens.
Btw, how do you view JDBC calls from the server? I don't know of any option in Enterprise Manager that allows me to do that.
Thanks,
Bo Zhu
Matt Weber [MSFT] wrote:
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:
- Re: Implicit conversion from data type text to nvarchar is not allowed.
- From: Angel Saenz-Badillos[MS]
- Re: Implicit conversion from data type text to nvarchar is not allowed.
- References:
- Implicit conversion from data type text to nvarchar is not allowed.
- From: Bo Zhu
- RE: Implicit conversion from data type text to nvarchar is not allowed.
- From: Matt Weber [MSFT]
- Implicit conversion from data type text to nvarchar is not allowed.
- Prev by Date: RE: Implicit conversion from data type text to nvarchar is not allowed.
- Next by Date: Re: Implicit conversion from data type text to nvarchar is not allowed.
- Previous by thread: RE: 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
|
Loading