Advertisement
Guest User

Untitled

a guest
Jan 31st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. public Connection login() {
  2. try {
  3. Class.forName("com.mysql.jdbc.Driver");
  4. } catch (ClassNotFoundException e1) {
  5. System.out.println("Connection registration error");
  6. e1.printStackTrace();
  7. }
  8. Properties connectionProps = new Properties();
  9. connectionProps.put("user", "librarian");
  10. connectionProps.put("password", "librarian");
  11. try {
  12. Main.setConnection(DriverManager.getConnection("jdbc:mysql://localhost:3306/javabase", connectionProps));
  13. connected = true;
  14. } catch (SQLException e) {
  15. Logger.getLogger(Login.class.getName()).log(Level.SEVERE, "Opening connection exception", e);
  16. }
  17. return Main.getConnection();
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement