Advertisement
Guest User

Untitled

a guest
Jul 6th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. private void connect()
  2.     {
  3.         System.out.print("DerbyConnection: Loading Driver..");
  4.         try
  5.         {
  6.             Class.forName(driver).newInstance();
  7.             System.out.println("DONE.");
  8.         } catch (ClassNotFoundException e)
  9.         {
  10.             System.err.println("\nDerbyConnection: Driver (" + driver
  11.                     + ") not found. [ClassNotFoundException]");
  12.             e.printStackTrace(System.err);
  13.         } catch (InstantiationException e)
  14.         {
  15.             System.err.println("\nDerbyConnection: Driver (" + driver
  16.                     + ") could not be loaded. [InstantiationException]");
  17.             e.printStackTrace(System.err);
  18.         } catch (IllegalAccessException e)
  19.         {
  20.             System.err.println("\nDerbyConnection: Driver (" + driver
  21.                     + ") could not be loaded. [IllegalAccessException]");
  22.             e.printStackTrace(System.err);
  23.         }
  24.         System.out.print("DerbyConnection: Connecting to database ..");
  25.         try
  26.         {
  27.             conn = DriverManager.getConnection(protocol + dbName
  28.                     + ";create=true;user=targas;password=swp");
  29.             System.out.println("DONE.");
  30.             conn.setAutoCommit(false);
  31.         } catch (SQLException e)
  32.         {
  33.             System.err
  34.                     .println("\nDerbyConnection: Could not connect to database ("
  35.                             + dbName + "). [SQLException]");
  36.             printSQLException(e);
  37.         }
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement