Mysql Web related error

Asked

Viewed 1,050 times

0

Hello, I am trying to connect a java class with a Mysql BD from the db4free.net host but 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 class of connection:

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();
    }

}
  • If you declare the method connect() as static? public static boolean connect() {...

  • It’s most likely the version of your Mysql driver, incompatible with the version of your Java. Tries to update the version (if using Maven: searches in the MVN Repo for mysql-Connector-java).

  • It did not work either to change the connect() method to statico, or updated mysql Connector, follows same error, in mwu mysql localhost connects normal.... I’ll keep searching, thanks for your help!

1 answer

-1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.