Domanda

I need to save some uni-code characters in Sql server 2005 DB with JDBC, When i try to save "O’CON" into DB column having type NVarchar using a stored procedure it saves "O?CON" `(where ’ character is not `` or ')

I did some R&D and found that i need to add useUnicode=true&characterEncoding=UTF-8 some where in my DBcon.properties file that contains all the details of DB connection,

Can some one help me out where to add this into properties file or it i can add it at run time when i create a connection object.

Or if someone can help me how to save unicodes characters in DB using java.

Thanks.

È stato utile?

Soluzione

To connect to database you use connect string specific to your database and driver.

I used MS MSQ long time ago but I remember that they had jtds driver. Connect string for such driver looks like:

jdbc:jtds:sqlserver://hostname:1433/my_database;useUnicode=true;characterEncoding=UTF-8

But from that time MS create their own JDBC driver and if you use it then I think you can add:

sendStringParametersAsUnicode=true

to your connect string. It is decribed at http://technet.microsoft.com/en-us/library/ms378988.aspx

In a case of problems show us your connect string and code where it is used.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top