Windows-1251 encoding problem with JBossCMP + MS SQL Server

Discussions

EJB programming & troubleshooting: Windows-1251 encoding problem with JBossCMP + MS SQL Server

  1. Hello,

    I would like to use JBossCMP for my project, because JBossCMP implementation of EJB 2.0 seems to be great!

    However, I encountered an encoding problem using JBossCMP with Microsoft SQL Server 2000 with the JDBC driver from Microsoft. When I ejbCreate() a new CMP entity using JBossCMP, I have strange symbols in my database. When I work directly via JDBC, everything is fine.

    ------------------
    My system is:

    AppServer:
    Windows 2000 Professional
    JBoss 3.0.0
    Tomcat 4.0.3 (other JVM)
    Microsoft JDBC Driver

    DB Server:
    Windows 2000 Advanced Server
    Microsoft SQL Server 2000 Enterprise
    ------------------

    I suspect MS JDBC Driver is causing the problem rather than JBoss. I had the same problem using PreparedStatement/MS JDBC Driver/MS SQL Server 2000, and am still confused why that happened. It works OK now. However, I have to use NVARCHAR, not VARCHAR.

    Another problem had been 'Cannot start a cloned connection while in manual transaction mode', which was solved by adding ';SelectMethod=cursor' to the connection string for the data source. Maybe there is a driver property setting that makes the encoding works ok?

    Has anyone encountered the same problem with encoding? Does anyone know a workaround?

    Any help is greatly appreciated!

    Sincerely,
    Sergei Batiuk.

  2.  Hi , Sergei !

     The Weblogic JDBC Driver for MS SQL has a driver property setting "weblogic.codeset". Users of the Weblogic JDBC Driver for MS SQL must set up the setting for "Windows-1251 " encoding.
     Does the Microsoft JDBC Driver have the same setting ?
     Look into Microsoft JDBC Driver's documentation.
     
     Hope this helps,
     Bogdan
  3. Hi Bogdan!

    Did you try the weblogic.codeset? Did it REALLY work for you? Did you use VARCHAR or NVARCHAR?

    I looked into the docs and found the only encoding-related property SendStringParametersAsUnicode=true|false, which is true by default. I tried false, which gave no effect.

    May be there is other SQL Server JDBC driver available for free?
  4. I have no experience with Microsoft's driver, but I do know that the OPTA2000 driver from www.inetsoftware.de handles Unicode characters correctly. You just have to use the NVARCHAR column type everywhere and make sure that the protocol in the JDBC URL is inetdae7, for example:

    jdbc:inetdae7:machinename?database=test

    The inetdae7a protocol, in contrast, only stores ASCII data.

    Regards,
    Pietari Laurila

  5.  Hi , Sergei !

     I'd tried this settting. It really works. It works with VARCHAR and NVARCHAR.
       
     Hope this helps