1

What is the way to connect with JDBC to a mySql database that is online?

mysql.info.mi.us:3006 = corresponds to the server of the database

mydatabases_2 = my databases

my try returning this error:

java.lang.NullPointerException

Class.forName("com.mysql.jdbc.Driver")
connexion = DriverManager.getConnection("jdbc:mysql://mysql.info.mi.us:3306", "user", "password");
3
  • Class.forName no longer is needed. Commented Nov 14, 2017 at 15:16
  • 1
    Show your StackTrace and more code. Commented Nov 14, 2017 at 15:20
  • The problem has nothing to do with your JDBC connection. You have a NullPointerException because something is not initialized. We are able to hack into your computer to solve the problem, but choose not to do so. Instead, consider posting the exception output. Commented Nov 14, 2017 at 15:31

2 Answers 2

2

Just append it:

connexion = DriverManager.getConnection("jdbc:mysql://mysql.info.mi.us:3006/mydatabases_2", "user", "password");
Sign up to request clarification or add additional context in comments.

2 Comments

always the same error "java.lang.NullPointerException"
U sure you are using the right port? sql db's tend to be on 3306 instead of 3006
0

Just a question: are you sure about the port? The default port of mysql is 3306, while you're using 3006. Are you sure the port is right?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.