mercredi 13 juillet 2016

netbeans IDE 8.1 for sql jdbc server not connecting

In my java-fx project, I need to connect to db4free through netbeans IDE 8.1. I add the following jar to my library:

mysql-connector-java-5.0.8-bin

and this is the code that throws exception:

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
   //password and username are correct for sure
public void start(){
Class.forName("com.mysql.jdbc.Driver");   //finds it
string host = "jdbc:mysql://db4free.net:3306/egyadb2016";
Connection con = DriverManager.getConnection(host, USERNAME, PASSWORD);
Statement stmt = con.createStatement(); //THROWS NULL POINTER EXCEPTION}

maybe netbeans is causing the problems? I do use java-fx project. ...HELP?

Aucun commentaire:

Enregistrer un commentaire