Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. public Connection connectToDatabaseAsSupplier(String name,String pass) {
  2. Connection connection = null;
  3. try {
  4. Class.forName("com.mysql.jdbc.Driver");
  5. String dbURL = "jdbc:mysql://localhost/bank";
  6. Properties properties = new Properties();
  7. properties.setProperty("user", name);
  8. properties.setProperty("password", pass);
  9. properties.setProperty("useSSL", "false");
  10. properties.setProperty("noAccessToProcedureBodies","true");
  11.  
  12.  
  13. connection = DriverManager.getConnection(dbURL, properties);
  14. }
  15. catch (Exception exception) {
  16. JOptionPane.showMessageDialog(null, "Establising database connection failed", "Error", JOptionPane.ERROR_MESSAGE);
  17. }
  18.  
  19. return connection;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement