匿名用户
1级
plsql配置数据库连接文件。2012-08-10 回答
public class DBUtil {
static{
oracle数据源配置,try {
Properties props = new Properties();
props.load(DBUtil.class.getClassLoader().getResourceAsStream("dbcp.properties"));
oracle配置监听文件,dataSource = BasicDataSourceFactory.createDataSource(props);
} catch (Exception e) {
e.printStackTrace();
sqlplus连接oracle?}
}
private static DataSource dataSource;
oracle用户权限。private static ThreadLocal conLocal = new ThreadLocal();
public static Connection openConnection()throws SQLException{
Connection con = conLocal.get();
if(con == null){
con = dataSource.getConnection();
conLocal.set(con);
}
return con;
}
public static void closeConnection()throws SQLException{
Connection con = conLocal.get();
conLocal.set(null);
if(con != null && !con.isClosed()){
con.close();
}
}
}
------dbcp.properties---------------------------------------------------------------
driverClassName=oracle.jdbc.driver.OracleDriver
url=jdbc:oracle:thin:@10.87.66.144:1521:orcl
username=scott
password=111111
initialSize=3
maxActive=15
maxIdle=2
minIdle=1
maxWait=30000
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态