Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- String driver = "com.mysql.jdbc.Driver";
- //String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
- // String url = "jdbc:odbc:northwind";
- //String username = "";
- //String password = "";
- Class.forName(driver);
- //Class.forName("com.mysql.jdbc.Driver").newInstance();
- //Logger.getLogger(DatabaseConnectie.class.getName()).log(Level.INFO, "Driver instantiated");
- con = DriverManager.getConnection("jdbc:mysql://localhost/" + connection, user, password);
- //con = DriverManager.getConnection("jdbc:mysql://localhost/" + connection + "?" +
- // "user=" + user + "&password=" + password);
- Logger.getLogger(DatabaseConnectie.class.getName()).log(Level.INFO, " Database connection made");
- result = true;
- } catch (ClassNotFoundException ex) {
- System.out.println("driver voor database " + connection + " is niet gevonden.");
- System.out.println(ex.getMessage());
- Logger.getLogger(DatabaseConnectie.class.getName()).log(Level.SEVERE, null, ex);
- //} catch (InstantiationException ex) {
- // Logger.getLogger(DatabaseConnectie.class.getName()).log(Level.SEVERE, null, ex);
- //} catch (IllegalAccessException ex) {
- // Logger.getLogger(DatabaseConnectie.class.getName()).log(Level.SEVERE, null, ex);
- } catch (SQLException ex) {
- Logger.getLogger(DatabaseConnectie.class.getName()).log(Level.SEVERE, null, ex);
- }
- return result;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement