Posted on 2006-09-22 10:36
Kevin Meng 阅读(404)
评论(0) 编辑 收藏
开发环境:
jdk 1.5
tomcat 5.0.28
oracle 9i
(1)在浏览器中输入http://localhost:8181/admin/,登陆tomcat管理系统
(2)选择Tomcat server->service->Host->Context(/yourproject)->Resource->Data Source
(3)在下拉列表中选择Create new DataSource
JNDI Name:jdbc/yourDatasourceName
Data Source URL:jdbc:oracle:thin:@menglikunm:1521:ora
JDBC Driver:oracle.jdbc.driver.OracleDriver
UserName:username
Password:password
Max. Active Connections:2000(自己定)
2
(自己定)
(4)把oracle 的class12.jar拷贝到tomcat的common/lib目录下(不要忘记这一步哦)
(5)重新启动Tomcat
(6)测试,代码如下:
Connection con = null;
try{
Context ctx=new InitialContext();
DataSource ds=(DataSource)ctx.lookup("java:comp/env/jdbc/ora_menglikunm");
con=ds.getConnection();
}catch(Exception ex){
ex.printStackTrace();
}
(7)加班作吧!!!!:)