数据库会出现乱码吗?你用String转码与数据库一致看看。
解决方案 »
- ssh('sessionFactory' or 'hibernateTemplate' is required)
- java学习进入困境了,请前辈们来解惑
- 求助:偶然的insert语句重复插入
- servlet问题
- 一个活见鬼的问题
- struts-config.xml中<action>下的validate属性如果没有设置,默认值是true还是false?
- 求助:帮忙看一个程序,我是一个初学者看不懂的说,急!!!!!!
- 帮我看看这个代码,连接oracle数据库的
- 初学jsp,散分!
- 使用jQuery的ajax提交表单后台返回的JSON数据在IE8下无法接收,总是undefined,其他浏览器却正常,跪求大神指教!
- 使用DB2查询的问题
- 新手求问——jsp页面如何获取服务器数据库的数据
只要在传输过程中,未再做任何的转码。
你接收后,可以使用string再重新编码一次还原回来的。这个理论上就好比是网页的东西,你通过网络访问以后,再转码回来。。
byte[] bytes = // 从 socket 或文件中读取。
String field = new String(bytes); // 这句相当于 new String(bytes, System.getProperty("file.encoding")); // 如果原来它是 UTF8 或其它编码方式编码的 byte [],那这个时候就是乱码。
// 所以我们需要给驱动程序说明它应该使用某个字符集而不使用操作系统默认的。 这个文章
How driver manager converts between Unicode and ANSI
中提到:
The only "working" solution i could figure out is to implement both
wide and ansi APIs and the user must specify which one internally
should be used and for the anis API, a character set must be specified.
For example the configuration string for my library could be
something like "engine=odbc;odbcapi=ansi;charset=utf8;DSN=mysource"or "engine=odbc;odbcapi=unicode;DSN=mysource"So if the user really needs to load a odbc 2.0 driver which only
returns iso-850 chars, he can configure my lib this way (extreme
example).I don't see any other chance to provide working odbc support. 但还是不知道怎么在写 JDBC 连接的 URL 中这样指定参数,它这个 ODBC 连接串不像是 JDBC 能识别的(?我也不确定,常见的 JDBC-ODBC URL 不是这么写的啊)
http://www.cs.lafayette.edu/docs/java/guide/jdbc/bridge.html
"engine=odbc;odbcapi=ansi;charset=utf8;DSN=mysource"
这种写法可能是 M$ 编程中的 OLEDB 之类的,反正不是 Java。
我也不想odbc ,没办法。这个数据库不支持jdbc所以。。