记一次sybase12.5 之com.sybase.jdbc3.jdbc.SybSQLException

昨天做多数据库兼容性测试是,在使用sybase数据库时候发现:

Caused by: com.sybase.jdbc3.jdbc.SybSQLException: Error converting characters into server's character set. Some

character(s) could not be converted.

 at com.sybase.jdbc3.tds.Tds.a(Unknown Source)
 at com.sybase.jdbc3.tds.Tds.nextResult(Unknown Source)
 at com.sybase.jdbc3.jdbc.ResultGetter.nextResult(Unknown Source)
 at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)
 at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)
 at com.sybase.jdbc3.jdbc.SybStatement.updateLoop(Unknown Source)
 at com.sybase.jdbc3.jdbc.SybStatement.executeUpdate(Unknown Source)
 at com.sybase.jdbc3.jdbc.SybPreparedStatement.executeUpdate(Unknown Source)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:585)
 at org.logicalcobwebs.proxool.ProxyStatement.invoke(ProxyStatement.java:100)
 at org.logicalcobwebs.proxool.ProxyStatement.intercept(ProxyStatement.java:57)
 at $java.sql.ParameterMetaData$$EnhancerByProxool$$572a21b0.executeUpdate()
 at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
 at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2247)
 ... 30 more

后分析发现SYBASE数据库的字符集是CP960,而且sybase里面也只安装了这一种字符集,所以首先装utf8字符集:

安装:

cmd
cd d:\sybase\charsets\utf8
charset -Usa -Psa_pass -Sserver_name binary.srt utf8

修改:

   在sybase数据库内设置选用此字符集为默认。

装好之后查看sp_configure,发现disable character set conversion为0也就是自动转换字符集,将他设置为1,重新测试一切OK,

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10130206/viewspace-630568/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10130206/viewspace-630568/

你可能感兴趣的:(记一次sybase12.5 之com.sybase.jdbc3.jdbc.SybSQLException)