Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1.  
  2. import java.sql.Connection;
  3. import java.sql.DriverManager;
  4. import java.sql.SQLException;
  5.  
  6. public class ConnectionFactory {
  7.    
  8.     static {
  9.         try {
  10.             Class.forName("com.mysql.cj.jdbc.Driver");
  11.         } catch (ClassNotFoundException ex) {
  12.             ex.printStackTrace();
  13.         }
  14.     }
  15.    
  16.     public static Connection conectar() throws SQLException {
  17.        
  18.         return DriverManager.getConnection
  19.                 ("jdbc:mysql://localhost/banco", "user",
  20.                         "u1s3e4r@@1f4d5AddDDq");
  21.        
  22.     }
  23.    
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement