Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. public class Connector {
  2.     public Connection polacz(){
  3.             try {
  4.         Class.forName("com.mysql.jdbc.Driver");
  5.     } catch (ClassNotFoundException e) {
  6.         System.out.println("Nie znaleziono Drivera ");
  7.         e.printStackTrace();
  8.        
  9.     }
  10.  
  11.     System.out.println("MySQL JDBC Driver Registered!");
  12.     Connection connection = null;
  13.  
  14.     try {
  15.         connection = DriverManager
  16.         .getConnection("jdbc:mysql://localhost:3306/test","admin", "");
  17.                 System.out.println("Connected to DB");
  18.  
  19.     } catch (SQLException e) {
  20.         System.out.println("Connection Failed! Check output console");
  21.         e.printStackTrace();
  22.        
  23.     }
  24.         return connection;
  25.     }
  26.    
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement