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

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

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

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

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

import java.sql.PreparedStatement;
import java.sql.Statement;
时间: 2024-12-14 00:45:14

Type mismatch: cannot convert from java.sql.PreparedStatement to com.mysql.jdbc.PreparedStatement的相关文章

java.lang.AbstractMethodError: Method com/mysql/jdbc/PreparedStatement.isClosed()Z is abstract

在学习Mybatis时出现下面的错误 1 java.lang.AbstractMethodError: Method com/mysql/jdbc/PreparedStatement.isClosed()Z is abstract 查阅资料后发现是Mybatis和mysql版本兼容问题 现在使用 <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis --> <dependency> <groupId>or

java.lang.Error: Unresolved compilation problems: Syntax error on token &quot;return&quot;, delete this token Type mismatch: cannot convert from Init to String

java.lang.Error: Unresolved compilation problems:   Syntax error on token "return", delete this token  Type mismatch: cannot convert from Init to String Dubbo 在调用服务时候报的错误! 那么问题来了.这什么错? ? 英语不好.     Type mismatch: cannot convert from Init to Strin

Type mismatch: cannot convert from Enumeration&lt;String&gt; to Enumeration&lt;Object&gt;

完整错误信息: Description Resource Path Location TypeType mismatch: cannot convert from Enumeration<String> to Enumeration<Object> ResponseHeaderFilter.java /dwz-java/src/dwz/common/util line 46 Java Problem 解决办法: Type mismatch: cannot convert from

关于Mysql数据库longblob格式数据的插入com.mysql.jdbc.PreparedStatement.setBinaryStream(ILjava/io/InputStream;J)V问题分析

当数据库字段为blob类型时 ,我们如果使用PreparedStatement中的setBinaryStream(int,InputStream,int)方法需要注意 在向blob字段类型中插入数据时,要使用javaio的inputstream,读入文件. 而相反从blob字段中读出数据时,同样使用javaio的inputstream,再用javaio的outputstream写入文件. 同clob的示例中的问题 如果在设置字节流的地方不加类型转换的话,如下: stat.setBinaryStr

Java Web程序开发链接MySQL数据库

显示错误:Access denied for user ''@'localhost' (using password: YES) 保证URL中没有空格 尝试用MySQL本地命令行登陆 显示错误:The import com.mysql.jdbc.Connection collides with another import statement 这句话是说com.mysql.jdbc.Connection重复导入 查看该jsp页面是否已导入额com.mysql.jdbc.Connection 显示

Error getting nested result map values for &#39;user_inf&#39;. Cause: java.sql.SQLException: Cannot convert

问题?Error getting nested result map values for 'user_inf'.  Cause: java.sql.SQLException: Cannot convert value '0000-00-00 00:00:00' from column 8 to TIMESTAMP. 错误:org.apache.ibatis.exceptions.PersistenceException: ### Error querying database.  Cause:

java sql

import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Savepoint;import java.sql.Statement; import com.mysql.jdbc.Driver; public class Sqltest

Java读取文件存储到mysql

写了一批Lua脚本,要放到数据库里面,调用的时候进行计算,由于有太多lua脚本,就写了个程序来录入. 下面主要分三个部分: public static String readToString(String fileName) public static void wirteToMYSQL(String string) throws FileNotFoundException public static List<String> getFileList(String strPath) readT

Package java.sql

Provides the API for accessing and processing data stored in a data source (usually a relational database) using the Java? programming language. This API includes a framework whereby different drivers can be installed dynamically to access different