工具类
package com.ch.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class DBUtil {
public final static String URL="**************";
public final static String DRIVER="****************";
public final static String USERNAME="*********";
public final static String PWD="*********";
static {
try {
Class.forName("DRIVER");
System.out.println("获取驱动成功");
} catch (Exception e) {
// TODO: handle exception
System.out.println("获取驱动失败");
e.printStackTrace();
}
}
public Connection getConnection() throws SQLException{
Connection conn = null;
conn = DriverManager.getConnection(URL,USERNAME,PWD);
return conn;
}
public void closeAll(ResultSet rst,PreparedStatement pst ,Connection conn){
if(rst!=null){
try {
rst.close();
} catch (SQLExc