MySQL Web connection error

0
Hello, I am trying to connect a java class with a MySQL BD from the db4free.net host but it is returning the error below:

SQLException: java.sql.SQLException: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long

Does anyone know what it can be?

My connection class:

import static java.lang.System.out;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConexaoMySQL {

private String user = "user";
private String pass = "pass";
private String dbClass = "com.mysql.jdbc.Driver";
private String dbDriver = "jdbc:mysql://db4free.net:3307/corrente";
private Connection conn = null;

public boolean connect() {
    boolean done = false;
    //load driver
    try {
        Class.forName(dbClass).newInstance();
        System.out.println("driver loaded"); // THIS IS BEING RETURNED
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
        System.err.println(ex);
    }
    // Connection
    try {
        conn = DriverManager.getConnection(dbDriver, user, pass);
        System.out.println("connected"); // THIS IS NOT BEING RETURNED
        done = true;
    } catch (SQLException ex) {
        System.out.println("SQLException: " + ex);
    }
    return done;
}
    public static void main(String[] args) {
        new ConexaoMySQL().connect();
    }

}
    
asked by anonymous 15.03.2017 / 03:24

1 answer

0

Download this connector: link

Unzip it to a folder and import mysql-connector-java-5.1.47-bin.jar into your project's library and use the same commands to connect to the DB.

    
26.08.2018 / 00:18