几种 mysql数据源_spring中几种数据源的配置(mysql)

1、dbcp

org.gjt.mm.mysql.Driver

jdbc:mysql://localhost:3306/exampledb?useUnicode=true&characterEncoding=utf8

exampleuser

thepass

500

100

20000

true

50

true

true

truevalue>

select 1 from dual

2、proxool

org.gjt.mm.mysql.Driver

jdbc:mysql://localhost:3306/exampledb?useUnicode=true&characterEncoding=utf8

exampleuser

thepass

spring

90000

5

100

10

1000

true

true

3、tomcat数据源

a、在tomcat的应用配置文件example.xml里配置数据源

url

jdbc:mysql://localhost:3306/exampledb?useUnicode=true&characterEncoding=utf8

password

thepass

maxActive

500

maxWait

20000

driverClassName

org.gjt.mm.mysql.Driver

username

exampleuser

maxIdle

100

b、Spring配置文件中配置:

java:comp/env/jdbc/exampleds

其它数据源网络上资料很多,不再赘述。

值得注意的是,如果配置tomcat数据源时出现报错内容为:url为null,driver为null的情况,可能是因为应用上下文配置里或者server.xml设置了 reloadable="true",此时tomcat不是完全启动,就无法找到url和driver。另外,数据库的驱动要放到tomcat的comon/lib下确保生效。经过多次测试,mysql-connector-java-3.0.16-ga-bin.jar驱动在使用hibernate时出现无法写数据库的bug,换成mysql-connector-java-3.1.12-bin.jar后一切正常。

分享到:

18e900b8666ce6f233d25ec02f95ee59.png

72dd548719f0ace4d5f9bca64e1d7715.png

2006-05-30 03:24

浏览 1089

评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值