resin jndi数据库连接池配置

web.xml文件


<database jndi-name='jdbc/testdb'>
<driver type="com.microsoft.sqlserver.jdbc.SQLServerDriver">
<url>jdbc:sqlserver://localhost:1433;database=dbname;</url>
<user>user</user>
<password>123456</password>
</driver>
<prepared-statement-cache-size>8</prepared-statement-cache-size>
<max-connections>10</max-connections>
<max-idle-time>20s</max-idle-time>
</database>



conf.properties
driver.sqlserver=net.sourceforge.jtds.jdbc.Driver
dbjndi.read.default=java:comp/env/jdbc/testdb
dbjndi.write.default=java:comp/env/jdbc/testdb

包:sqljdbc.jar
部分代码

public int openConn(String dbName) {
try {
String jndiName = appconf.get(dbName);
DataSource ds = (DataSource) cachtable.get(jndiName);
if (ds == null) {
Context ctx = new InitialContext();
ds = (DataSource) ctx.lookup(jndiName);
cachtable.put(jndiName, ds);
}
conc = ds.getConnection();
return 0;
} catch (Exception e) {
e.printStackTrace();
return -1;
}
}


resin3.0和resin4.0都测试成功
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值