Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static Connection establishConnection(){
- try{
- Class.forName("com.mysql.jdbc.Driver"); //The name of the SQL Driver
- connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/bapers?useUnicode=true&characterEncoding=utf-8&useSSL=false", username, password); //Create a connection to the database
- JOptionPane.showMessageDialog(null, "Connection successful!"); //Show a pop-up dialogue if the connection is successful
- return connection;
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return connection;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement