Guest User

Untitled

a guest
Jan 16th, 2018
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. public class Connect {
  2.     static String url = "jdbc:mysql://localhost:3306/bazy?autoReconnect=true&useSSL=false&useUnicode=yes&characterEncoding=UTF-8";
  3.  
  4.     static String username = "root";
  5.     static String password = "root";
  6.  
  7.     protected static Connection connection = null;
  8.  
  9.     public static void connectToDatabase() {
  10.         try {
  11.             Class.forName("com.mysql.jdbc.Driver");
  12.             connection = DriverManager.getConnection(url, username, password);
  13.  
  14.         } catch (Exception e) {
  15.             System.err.println("Got an exception (Connect)! ");
  16.             System.err.println(e.getMessage());
  17.         }
  18.     }
  19. }
Add Comment
Please, Sign In to add comment