Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package bapers;
- import java.sql.*;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import javax.swing.JOptionPane;
- public class SQLConnection {
- Connection conn = null;
- public static Connection ConnectDB(){
- try{
- Class.forName("com.mysql.jdbc.Driver"); //The name of the sql driver
- Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/bapers","root","detroy"); //Need root username and password to access database
- //JOptionPane.showMessageDialog(null, "Connected to database!"); //Message dialog for successfull connection
- return conn;
- }catch(Exception e){
- JOptionPane.showMessageDialog(null, e);
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement