线程“main”java.lang.Error 中的异常:未解决的编译问题:类型不匹配:无法从 java.sql.Statement 转换为 com.mysql.jdbc.Statement
我是java的初学者我正在尝试使用mysql数据库我已经从mysql.com下载了mysql-connector-java-5.1.23-bin.jar文件并且我已经将此jar文件添加到我的项目的构建路径中但是以下代码中有错误 线程“main”java.lang.Error中的异常:未解决的编译问题:类型不匹配:无法从java.sql.Statement转换为com.mysql.jdbc.Statement
package com.example.demo;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
public class DBConnect
{
private static final String userName = "root";
private static final String userpwd = "sverma";
private static final String CONN_STR = "jdbc:mysql://localhost:3306/phpweb_db";
public static void main(String[] args) throws SQLException
{
Connection conn = null;
Statement st = null;
ResultSet rs = null;
try
{
DriverManager.getConnection(CONN_STR, userName, userpwd);
st=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = st.executeQuery("select * from user");
rs.last();
System.out.println("No of rows: " + rs.getRow());
// System.out.println("Connected Successfully...");
}
catch (SQLException e)
{
System.err.println(e);
}
finally
{
if (rs != null)
{
rs.close();
}
if (st != null)
{
st.close();
}
if (conn != null)
{
conn.close();
}
}
}
}