[java]代码库
//Oracle JDBC
protected static String driverName = "oracle.jdbc.driver.OracleDriver";
protected static String url = "jdbc:oracle:thin:@localhost:1521:test";
protected static String dbuser = "";
protected static String pwd = "";
Connection conn= null;
try{
if(conn == null){
Class.forName(driverName);
conn = DriverManager.getConnection(url,dbuser,pwd);
System.out.println("加载驱动……");
}
System.out.println(conn+"加载成功!");
}
catch(SQLException sqlex){
sqlex.printStackTrace();
System.out.println(sqlex);
}
catch(Exception ex)
{
ex.printStackTrace();
}
finally
{
try{
if(conn != null)
conn.close();
System.out.println("数据连接关闭成功!");
}catch(Exception e){
e.printStackTrace();
}
}
初级程序员
by: 微微 发表于:2016-08-22 18:01:55 顶(0) | 踩(0) 回复
回复评论