Пример #1
0
 public static void closeConnection() {
   try {
     if (rs != null) rs.close();
     if (stmt != null) stmt.close();
     if (con != null) con.close();
   } catch (SQLException ex) {
     ex.printStackTrace();
   }
 }
Пример #2
0
 public static Connection createConnection() throws NamingException {
   try {
     Class.forName("com.mysql.jdbc.Driver");
     con = DriverManager.getConnection("jdbc:mysql://sc0181:3306/forms_db", "test", "123321");
   } catch (SQLException e) {
     e.printStackTrace();
   } catch (Exception e) {
     e.printStackTrace();
   }
   return con;
 }