简体   繁体   English

jdbc 字符串 sql 服务器字符编码

[英]jdbc string sql server character encoding

If I have a jdbc string such as...如果我有一个 jdbc 字符串,例如...

jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]

How do you say "connect with character encoding as utf-8 like you can if you were connecting with mysql?你怎么说“如果你连接 mysql,你可以像 utf-8 那样连接字符编码?

Thanks,谢谢,

Did you try, as in Php,您是否尝试过,如 Php,

jdbc:sqlserver://serverName\instanceName;CharacterSet=UTF-8

Regards, stéphane问候, 斯蒂芬

According to the documentation, there is no such property in the URL schema .根据文档, URL 架构中没有这样的属性 But you probably don't need it anyway.但你可能无论如何都不需要它。 The JDBC driver will take your strings in Java Unicode and return all values in Java Unicode. The JDBC driver will take your strings in Java Unicode and return all values in Java Unicode. In Java it does not matter which character encoding the driver uses for communication with the DB (unless you do something really unusual, like trying to work around database bugs, or your database is not aware of the encoding of its content).在 Java 中,驱动程序使用哪种字符编码与 DB 通信无关紧要(除非您做了一些非常不寻常的事情,例如尝试解决数据库错误,或者您的数据库不知道其内容的编码)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM