代码:
package hw02;
import java.sql.*;
public class HW02
{
public static void main(String[] args) throws
SQLException,ClassNotFoundException
{
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Driver loaded");
String url = "jdbc:mysql://localhost/";
Connection conn = DriverManager.getConnection (url, "root",
"sesame");
System.out.println("Databse connected");
//Create a statement"
Statement statement = conn.createStatement();
ResultSet resultSet = statement.executeQuery("select * from
Phones.Products");
System.out.println("ResultSet completed");
while (resultSet.next())
{
System.out.println(resultSet.getString(1)+"\t" +
resultSet.getString(2) + "\t" +
resultSet.getString(3) + "\t" + "\n");
}
//close the connection
}
}
这会不断出现Casting错误提示
Exception in thread "main" java.sql.SQLException:
java.lang.ClassCastException: java.math.BigInteger cannot be cast to
java.lang.Long
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
at
我环顾四周,人们建议更换连接器,但我不知道该怎么做。