2008-07-18
tomcat 中配置Oracle DataSource
关键字: 数据源的配置
1. 在Context添加如下代码,定义DataSource
2. web.xml添加如下代码
3访问DataSource
<Resource name="jdbc/myoracle" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@127.0.0.1:1521:mysid"
username="scott" password="tiger" maxActive="20" maxIdle="10"
maxWait="-1"/>
2. web.xml添加如下代码
<resource-ref> <description>Oracle Datasource example</description> <res-ref-name>jdbc/myoracle</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref>
3访问DataSource
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");
Connection conn = ds.getConnection();
//获得数据库的连接
- 23:37
- 浏览 (109)
- 论坛浏览 (152)
- 评论 (0)
- 相关推荐
最近加入圈子
最新评论
-
tapestry4解决数据库重复 ...
hanfengmvp 写道 其实我到不觉的这个是什么问题,数据量大慢一点就慢一点 ...
-- by lean1252 -
tapestry4解决数据库重复 ...
其实我到不觉的这个是什么问题,数据量大慢一点就慢一点吧,如果你让数据第一次读取进 ...
-- by hanfengmvp -
tapestry4解决数据库重复 ...
谢谢你的建议,我去试试:)
-- by lean1252 -
tapestry4解决数据库重复 ...
使用Tacos的@Cached
-- by tapestry -
spring测试发现的问题
引用引用引用[flash=200,200][/flash][url][/url] ...
-- by ggh1232008







评论排行榜