Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Connection login() {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- } catch (ClassNotFoundException e1) {
- System.out.println("Connection registration error");
- e1.printStackTrace();
- }
- Properties connectionProps = new Properties();
- connectionProps.put("user", "librarian");
- connectionProps.put("password", "librarian");
- try {
- Main.setConnection(DriverManager.getConnection("jdbc:mysql://localhost:3306/javabase", connectionProps));
- connected = true;
- } catch (SQLException e) {
- Logger.getLogger(Login.class.getName()).log(Level.SEVERE, "Opening connection exception", e);
- }
- return Main.getConnection();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement