Advertisement
Guest User

Untitled

a guest
Sep 18th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3. import java.sql.SQLException;
  4.  
  5. public class TestMySQLConnection {
  6. static String username = "root";
  7. static String password = "root";
  8. // static String dbUrl = "jdbc:mysql://localhost:3306/world?autoReconnect=true&useSSL=false";
  9. static String dbUrl = "jdbc:mysql://localhost:3306/world";
  10. public static void main (String[] args) throws SQLException {
  11. Connection conn = null;
  12. try {
  13. conn = DriverManager.getConnection(dbUrl, username, password);
  14. System.out.println("Connection established to MYSQL database");
  15. } catch (SQLException e) {
  16. System.err.println(e.getMessage());
  17. }
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement