Type mismatch: cannot convert from java.sql.PreparedStatement to com.mysql.jdbc.PreparedStatement

Connection.prepareStatement()函数出错,提示:

Type mismatch: cannot convert from java.sql.PreparedStatement to com.mysql.jdbc.PreparedStatement

这是因为引入的包不对头,

import com.mysql.jdbc.PreparedStatement;
import com.mysql.jdbc.Statement;

引入正确的包就没有这个错误了。

import java.sql.PreparedStatement;
import java.sql.Statement;

 

你可能感兴趣的:(Type mismatch: cannot convert from java.sql.PreparedStatement to com.mysql.jdbc.PreparedStatement)