none
Can sendStringParametersAsUnicode=false be overriden/changed for certain cases

    Question

  • Configuration:  MS SQL server 2005 SP2, and MS jdbc driver version: 1.1
    The sendStringParameterAsUnicode has been set to false for performance reasons. However, when inserting unicode data, we would like to override the setting and send the data encoded in unicode, instead of defaulting the whole app to unicode=true and take a performance hit.

    Any suggestions? We have tried the cast(? as nvarchar) function, but that did not help.

    Sample code/output:
    String text = "\u0143\u0144";
    sendStringParametersAsUnicode=false
    insert into unitable (_ntext) values (?)
    Inserting into databse:
    143 144 (printed hex values)
    Read from database:
    3f 3f  (printed hex values)
    Tuesday, September 04, 2007 10:51 PM

Answers

  • Unicode is the native string representation for communication with SQL Server, if you are converting to MBCS, then you are doing 2 converts for every string.  I suggest that if you are concerned with performance, use all Unicode instead of all MBCS.

     

    Hope that helps,

     

    John

    Wednesday, September 05, 2007 5:35 PM
    Moderator
  • Details at:
    http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?cat=en_us_37eacc47-2e30-4a64-841b-c94b5716569a&lang=en&cr=us&guid=&sloc=en-us&dg=microsoft.public.sqlserver.jdbcdriver&tid=25b3259e-8e4f-4552-808d-15747c8b3fd9&mid=4381b5d6-31c5-49c1-b378-f377205eb5bd&amid=4381b5d6-31c5-49c1-b378-f377205eb5bd&answer=1&p=1&stgxml=http%3a%2f%2fwww.microsoft.com%2fcommunities%2fnewsgroups%2flist%2fen-us%2fsettings.xml
    Friday, September 07, 2007 8:27 PM

All replies

  • Unicode is the native string representation for communication with SQL Server, if you are converting to MBCS, then you are doing 2 converts for every string.  I suggest that if you are concerned with performance, use all Unicode instead of all MBCS.

     

    Hope that helps,

     

    John

    Wednesday, September 05, 2007 5:35 PM
    Moderator
  • Hello,

     

    Sample code will be great in helping to answering this question. I am interested in what API calls are being made to insert and retrieve the data (stmt.execute(), pstmt.setString(), rs.getString(), rs.getCharacterStream(), etc).

     

    Additionally, the following diagnostic information may help:

    SQL Server Collation.

    SQL Server Machine Language.

    Client machine Language.

     

    I'll assume the client and server machines are distinct. Therefore, let's clarify where the data is being improperly converted. After insertion, is the data accurate on the server?

     

    Kind Regards,

    Jaaved

     

    Friday, September 07, 2007 5:03 AM
    Moderator
  • Details at:
    http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?cat=en_us_37eacc47-2e30-4a64-841b-c94b5716569a&lang=en&cr=us&guid=&sloc=en-us&dg=microsoft.public.sqlserver.jdbcdriver&tid=25b3259e-8e4f-4552-808d-15747c8b3fd9&mid=4381b5d6-31c5-49c1-b378-f377205eb5bd&amid=4381b5d6-31c5-49c1-b378-f377205eb5bd&answer=1&p=1&stgxml=http%3a%2f%2fwww.microsoft.com%2fcommunities%2fnewsgroups%2flist%2fen-us%2fsettings.xml
    Friday, September 07, 2007 8:27 PM
  • I am glad to see this solved on the newsgroups.
    Thanks,
    Jaaved
    Saturday, September 08, 2007 5:46 AM
    Moderator