标签:java conf contex password oca resource 配置 driver classname
1、配置Tomcat的conf/context.xml
<Resource name="jdbc/news"
auth="Container" type="javax.sql.DataSource" maxActive="100"
maxIdle="30" maxWait="10000" username="scott" password="tiger"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:news"/>
2、使用JNDI获取连接对象
要添加这个协议:java:comp/env/jdbc/lovers
例如:
//1.初始化上下文
Context ctt=new InitialContext();
DataSource ds=(DataSource) ctt.lookup("java:comp/env/jdbc/lovers");
标签:java conf contex password oca resource 配置 driver classname
原文地址:https://www.cnblogs.com/luckgood/p/11737228.html