Advertisement
Guest User

SQLConnection

a guest
Feb 28th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3.  
  4. import javax.swing.JOptionPane;
  5.  
  6. public class SQLConnection {
  7. static Connection conn;
  8. public static Connection ConnecrDb()
  9. {
  10.     try {
  11.         Class.forName("com.mysql.jdbc.Driver");
  12.         Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/sms","root","");
  13.      //JOptionPane.showMessageDialog(null, "Success");
  14.      return conn;
  15.      
  16.     } catch(Exception e)
  17.     {
  18.         JOptionPane.showMessageDialog(null, "Failed");
  19.         return null;
  20.     }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement