看到论坛的一个帖子:
http://www.iteye.com/topic/9489
后来lz用在数据源url后加上“;instance=future;charset=CP936 ”就ok了,我也这样试了,但是没加这一句我可以正常添加到数据库,只是中文是乱码,但是加了这一句反而添加不了,好像都没法正确让程序读取这个url,读取的时候提示“can not get connection”。我的数据源配置如下:
xml 代码
-
<
Context
path
=
“/hibernate”
docBase
=
“E:\programming\java\eclipse_workplace2\hibernate\WebRoot”
debug
=
“0”
reloadable
=
“true”
crossContext
=
“true”
>
-
<
Resource
-
factory
=
“org.apache.commons.dbcp.BasicDataSourceFactory”
-
name
=
“jdbc/hibernate”
-
auth
=
“Container”
-
type
=
“javax.sql.DataSource”
-
maxActive
=
“100”
-
maxIdle
=
“30”
-
maxWait
=
“10000”
-
username
=
“test_hibernate”
-
password
=
“test_hibernate”
-
driverClassName
=
“net.sourceforge.jtds.jdbc.Driver”
-
url
=
“jdbc:jtds:sqlserver://192.168.0.6:1433/test_hibernate;instance=future;charset=CP936”
-
/>
url中去掉“instance=future;charset=CP936 ”可以正常插入数据库。