`
klts
  • 浏览: 39250 次
  • 性别: Icon_minigender_2
  • 来自: 成都
社区版块
存档分类
最新评论
  • klts: 我一直用的jdk1.6.0_13,感觉还可以
    JDK
  • wuyulunbi: 现在jdk什么版本的稳定
    JDK

JNDI

 
阅读更多
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)
  envCtx.lookup("jdbc/EmployeeDB");

Connection conn = ds.getConnection();
... use this connection to access the database ...
conn.close();

 config tomcat's resource factory

<Context ...>
  ...
  <Resource name="jdbc/EmployeeDB" auth="Container"
            type="javax.sql.DataSource" username="dbusername" password="dbpassword"
            driverClassName="org.hsql.jdbcDriver" url="jdbc:HypersonicSQL:database"
            maxActive="8" maxIdle="4"/>
  ...
</Context>

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics