ITeye博客

tomcat 中配置Oracle DataSource

lean1252 · 2008-07-18 23:37 · helper · 企业架构 · Java · SQL · JDBC · Tomcat · Oracle · Markdown

1. 在Context添加如下代码,定义DataSource [code="java"] [/code] 2. web.xml添加如下代码 [code="java"] Oracle Datasource example jdbc/myoracle javax.sql.DataSource Container [/code] 3访问DataSource [code="java"]Context initContext = new InitialContext(); Context envContext = (Context)initContext.lookup("java:/comp/env"); DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle"); Connection conn = ds.getConnection(); //获得数据库的连接[/code]

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。