无法将netbeans连接到mysql服务器,获取异常

时间:2018-05-05 17:11:26

标签: java mysql netbeans

我一直试图将netbeans连接到mysql服务器好几天了,我重新安装了mysql并更改了身份验证设置;更改了我的connector / j jar文件。

我确实得到了#34;连接成功!"当我建立与数据库的连接时,我可以查看他们的数据。但我不断得到这些例外: -

  

java.sql.SQLException:java.lang.ClassCastException:java.math.BigInteger无法强制转换为java.lang.Long   java.math.BigInteger无法强制转换为java.lang.Long

这是我的代码: -

  public static void main(String[] args) {
    // TODO code application logic here
    String s="";
    try{
    String url="jdbc:mysql://localhost:3306/mma"; 
    String user="root";
    String password="Reshteenbb4905";
    Connection c=DriverManager.getConnection(url, user, password); 
    //Connection c=DriverManager.getConnection(url);
    //
    Statement stat=c.createStatement();
    ResultSet result=stat.executeQuery("select ProductID from product "
            + "where ProductID='1'");
    ResultSet result2=stat.executeQuery("select * from product");
    while(result2.next()){
        int i=result2.getInt(1);
        s=result2.getString(2);
        String description=result2.getString(3);
        double d= result2.getDouble(4);
    }
    result.close();
    //ResultSet result2=stat.executeQuery("select * from product");
    //boolean cursor=result.next();
    }catch(SQLException e){
        for(Throwable t:e){
            System.out.println(t);
            e.getMessage();
        }
      //  e.printStackTrace();
    }   
}

0 个答案:

没有答案