public class DBUtil {
static String url="jdbc:mysql://localhost:3306/eshop?useUnicode=true&characterEncoding=UTF-8 ";
static String user="root";
static String password="123";
static Connection con;
public static Connection getCon() {
try {
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection(url,user,password);
return con;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static void close(ResultSet rs,PreparedStatement ps,Connection con) {
try {
if(rs != null) {
rs.close();
}
if(ps != null) {
ps.close();
}
if(con != null) {
con.close();
}
}catch(Exception e) {
e.printStackTrace();
}
}
}
static String url="jdbc:mysql://localhost:3306/eshop?useUnicode=true&characterEncoding=UTF-8 ";
static String user="root";
static String password="123";
static Connection con;
public static Connection getCon() {
try {
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection(url,user,password);
return con;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static void close(ResultSet rs,PreparedStatement ps,Connection con) {
try {
if(rs != null) {
rs.close();
}
if(ps != null) {
ps.close();
}
if(con != null) {
con.close();
}
}catch(Exception e) {
e.printStackTrace();
}
}
}