
package dao;
import java.sql.*;
public class BaseDao {
private static final String DRIVER="com.microsoft.sqlserver.jdbc.SQLServerDriver";
private static final String URL="jdbc:sqlserver://localhost:1433;databaseName=ymw";
private static final String USBR="hs";
private static final String PWD="123";
public static Connection con;
public static PreparedStatement ps;
public static ResultSet rs;
public static CallableStatement cs;
public static Connection getCon(){
try {
Class.forName(DRIVER);
con=DriverManager.getConnection(URL,USBR,PWD);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return con;
}
public void closeAll(Connection con,CallableStatement cs,ResultSet rs){
try {
if(null!=rs){
rs.close();
}if(null!=ps){
ps.close();
}if(null!=con){
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
import java.sql.*;
public class BaseDao {
private static final String DRIVER="com.microsoft.sqlserver.jdbc.SQLServerDriver";
private static final String URL="jdbc:sqlserver://localhost:1433;databaseName=ymw";
private static final String USBR="hs";
private static final String PWD="123";
public static Connection con;
public static PreparedStatement ps;
public static ResultSet rs;
public static CallableStatement cs;
public static Connection getCon(){
try {
Class.forName(DRIVER);
con=DriverManager.getConnection(URL,USBR,PWD);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return con;
}
public void closeAll(Connection con,CallableStatement cs,ResultSet rs){
try {
if(null!=rs){
rs.close();
}if(null!=ps){
ps.close();
}if(null!=con){
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
