java怎么连接oracle数据库连接
展开全部
public static ResultSet oracleConn(String sql) {
String driver = "oracle.jdbc.driver.OracleDriver";
//写明你数据的连接串
String url = "jdbc:Oracle:thin:@192.168.1.1:3004/者穗xe";
Statement stmt = null;
ResultSet res = null;
Connection conn = null;
CallableStatement proc = null;
List<SqlResult> list = new ArrayList();
try {
Class.forName(driver);
//连接数据库
conn = DriverManager.getConnection(url, "username",
"password");
stmt = conn.createStatement();
/仔渗/执行sql语句,首戚卜并返回结果
res = stmt.executeQuery(sql);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return res ;
}
String driver = "oracle.jdbc.driver.OracleDriver";
//写明你数据的连接串
String url = "jdbc:Oracle:thin:@192.168.1.1:3004/者穗xe";
Statement stmt = null;
ResultSet res = null;
Connection conn = null;
CallableStatement proc = null;
List<SqlResult> list = new ArrayList();
try {
Class.forName(driver);
//连接数据库
conn = DriverManager.getConnection(url, "username",
"password");
stmt = conn.createStatement();
/仔渗/执行sql语句,首戚卜并返回结果
res = stmt.executeQuery(sql);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return res ;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询