类型不匹配:无法从连接转换为连接 [英] Type mismatch: cannot convert from Connection to Connection
问题描述
我想通过JDBC连接到MSaccess. 但是
I want JDBC connection to MSaccess. But
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:access");
给出
类型不匹配:无法从连接转换为连接
Type mismatch: cannot convert from Connection to Connection
有什么解决方案?
我正在使用Servlet和jsp 在jsp中-
I m using Servlet and jsp in jsp -
Organization Name: <input type="text" name="Organization_name" ><br>
我希望在输入Organization_name时将其添加到我的访问权限数据库中 我已经尝试过,但是我面临以下问题
i want when Organization_name entered it will be add it in my access database i have tried but i m facing following problem
Connection con = DriverManager.getConnection("jdbc:odbc:access");
它给出类型不匹配:无法从Connection转换为Connection
推荐答案
您需要从java.sql
中获取Connection
,似乎您导入了错误的类
you need Connection
from java.sql
it seems you have imported a wrong class
和getConnection()
需要完整的jdbc URL
.
and getConnection()
needs complete jdbc URL
.
简单地说,您的代码应具有以下导入
In very simple words your code should have following imports
import java.sql.Connection
这篇关于类型不匹配:无法从连接转换为连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!