hq369 发表于 2013-2-3 14:01:40

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都测试成功
页: [1]
查看完整版本: resin jndi数据库连接池配置