找不到借口..
package JDBC; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import com.mysql.jdbc.Statement; public class jdbc { private static final String URL ="jdbc:mysql://127.0.0.1:3306/zhao"; private static final String USER ="root"; private static final String PASSWORD =""; public static void main(String[] args) throws Exception { // 加载驱动程序 Class.forName("com.mysql.jdbc.Driver"); // 获取数据库连接 Connection conn = DriverManager.getConnection(URL, USER, PASSWORD); // 通过数据库连接操纵数据库。实现增删查改 Statement stmt=(Statement) conn.createStatement(); ResultSet rs = stmt .executeQuery("select user_name,age from imocc_goddess"); while (rs.next()) { System.out.println(rs.getString("user_name") + "," + rs.getInt("age")); } } }
报错说:
Exception in thread "main" java.lang.IncompatibleClassChangeError: Found class com.mysql.jdbc.Statement, but interface was expected
at JDBC.jdbc.main(jdbc.java:25)