Advertisement
Guest User

sql code

a guest
Apr 5th, 2018
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. package bapers;
  2.  
  3. import java.sql.*;
  4. import java.util.logging.Level;
  5. import java.util.logging.Logger;
  6. import javax.swing.JOptionPane;
  7.  
  8. public class SQLConnection {
  9. Connection conn = null;
  10. public static Connection ConnectDB(){
  11. try{
  12. Class.forName("com.mysql.jdbc.Driver"); //The name of the sql driver
  13. Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/bapers","root","detroy"); //Need root username and password to access database
  14. //JOptionPane.showMessageDialog(null, "Connected to database!"); //Message dialog for successfull connection
  15. return conn;
  16. }catch(Exception e){
  17. JOptionPane.showMessageDialog(null, e);
  18. return null;
  19. }
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement