package com.yinhai.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
public class JdbcUtil
{
static{
String driver = "oracle.jdbc.driver.OracleDriver";
try{
Class.forName(driver);
}catch(Exception e){
e.printStackTrace();
}
}
public static Connection getConnection(){
String url =
"jdbc:oracle:thin:@192.192.192.239:1521:orcl";
String usr = "xajgyl";
String pwd = "xajgyl";
Connection con = null;
try{
con = DriverManager.getConnection(url,usr,pwd);
}catch(Exception e){
e.printStackTrace();
}
return con;
}
public static void close(ResultSet rs, Statement stmt,Connection con){
try{
if(rs!=null) rs.close();
}catch(Exception ex){
ex.printStackTrace();
}
try{
if(stmt!=null) stmt.close();
}catch(Exception ex){
ex.printStackTrace();
}
try{
if(con!=null) con.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
}
JDBC工具类
最新推荐文章于 2022-06-16 16:02:05 发布