Advertisement
Guest User

Untitled

a guest
Jun 14th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.58 KB | None | 0 0
  1. try {
  2.             String driver = "com.mysql.jdbc.Driver";
  3.             //String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
  4.             // String url = "jdbc:odbc:northwind";
  5.             //String username = "";
  6.             //String password = "";
  7.             Class.forName(driver);
  8.  
  9.             //Class.forName("com.mysql.jdbc.Driver").newInstance();
  10.             //Logger.getLogger(DatabaseConnectie.class.getName()).log(Level.INFO, "Driver instantiated");
  11.  
  12.             con = DriverManager.getConnection("jdbc:mysql://localhost/" + connection, user, password);
  13.             //con = DriverManager.getConnection("jdbc:mysql://localhost/" + connection + "?" +
  14.                // "user=" + user + "&password=" + password);
  15.             Logger.getLogger(DatabaseConnectie.class.getName()).log(Level.INFO, " Database connection made");
  16.             result = true;
  17.  
  18.         } catch (ClassNotFoundException ex) {
  19.             System.out.println("driver voor database " + connection + " is niet gevonden.");
  20.             System.out.println(ex.getMessage());
  21.             Logger.getLogger(DatabaseConnectie.class.getName()).log(Level.SEVERE, null, ex);
  22.             //} catch (InstantiationException ex) {
  23.             // Logger.getLogger(DatabaseConnectie.class.getName()).log(Level.SEVERE, null, ex);
  24.             //} catch (IllegalAccessException ex) {
  25.             //    Logger.getLogger(DatabaseConnectie.class.getName()).log(Level.SEVERE, null, ex);
  26.         } catch (SQLException ex) {
  27.             Logger.getLogger(DatabaseConnectie.class.getName()).log(Level.SEVERE, null, ex);
  28.         }
  29.  
  30.         return result;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement