连接Oracle数据库帮助类
时间:2021-07-01 10:21:17
帮助过:3人阅读
/**
* 数据库连接帮助类
* @author zql_pc
*
*/
public class DbHelp {
/*
* 数据库连接
*/
public static Connection lianjie(){
//数据库配置
String driver = "oracle.jdbc.driver.OracleDriver";
//驱动
String url = "jdbc:oracle:thin:
@localhost:
1521:JBITDB";
String user = "epet";
String pwd = "
123456";
try {
//第一步:加载驱动
Class.forName(driver);// -->反射
Connection conn = DriverManager.getConnection(url,
user,pwd);
return conn;
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
}
连接Oracle数据库帮助类
标签: