- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
java中Connection接口(interface)的prepareStatement在JDBC中的实现在哪里?
String sql = "update people set firstname=? , lastname=? where id=?";
PreparedStatement preparedStatement = connection.prepareStatement(sql);
我找不到连接接口(interface)的实现,我们直接调用连接接口(interface)的方法,但必须有实现连接接口(interface)的类。如果没有实现连接接口(interface)的类,那么它是如何工作的?
有人可以解释一下吗?
最佳答案
...we directly call the methods of Connection interface but there must be class which would be implementing the Connection interface.
是的,你完全正确。 Connection
接口(interface)由 JDBC 提供程序库实现,而不是在 JDK 本身中实现,因为它特定于您正在使用的 RDBMS。所以有一个 MySQL Connection
实现,一个 SQL Server 实现,等等。您通常从 Driver
(直接或间接)获得一个 Connection
,它您从 DriverManager
(直接或间接)获取,您从 RDBMS 的 JDBC 驱动程序 jar 加载它。
关于java - JDBC中使用的java中**Connection接口(interface)**的**prepareStatement**的实现在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26065214/
我正在尝试使用以下命令执行准备好的语句: dbaBean.setPrepStmt(dbaBean.getConn().prepareStatement( "SELECT id, author,
当 id 是我的 SQL 表的键时,我使用 prepareStatement() 它将由 SQL 创建,我想使用这个语句 :(我应该写什么而不是 SQL 表第一列中的 X(提醒:SQL 自动创建) F
我在这个函数中遇到错误,但我不知道为什么。你能帮帮我吗? 错误在我调用 executeQuery() 的行中 public static int numeroElementi(String table
我正在尝试使用 prepareStatement 函数。代码如下。执行后,它会返回一堆 vlicense 字符串而不是值。 当代码完成 statement.setString() 时,语句变为: se
我正在尝试使用 prepareStatement 将数据插入 mysql 数据库,但它显示错误,如 Type mismatch: cannot convert from java.sql.Prepar
整个数据操作如下。我想关闭每个资源而不干扰下一个连接。我应该将构造函数更改为connection()方法,然后使用disconnect()方法,但是这样做之后我应该在哪里 public class D
在像这样的 prepareStatement 中运行此查询时 SELECT SYSDATE + INTERVAL '7' DAY FROM DUAL; PreparedStatement ps
我尝试使用 prepareStatement 查询 sqlite,但遇到异常: java.sql.SQLException: not supported by PreparedStatment
我在某处看到了这个例子: rs = connection.prepareStatement("select * from table").executeQuery(); 如果我想执行这样的查询“ S
我注意到有很多关于CreateStatement 与PreparedStatement 的帖子,但是我的问题不同(只是为了通知这不是这些搜索结果之一的重复) 当我从 java 代码查询数据库时,我可以
我是 eclipse 的新手,我正在尝试创建一个注册界面。作为一个外壳,它工作得很好,即如果没有给出输入,它会接受输入并显示警告,但它没有连接到数据库。我现在尝试使用prepareStatement
我已阅读prepareStatement(String sql)的描述还有很多与PreparedStatement的性能和缓存相关的帖子,我很清楚数据库将解析和编译准备好的语句的查询,这样对于后续相同
当我尝试使用准备好的语句更新 SQL 数据库时,我不知道为什么我的代码在 executeUpdate(sql) 时出错。当我尝试在 Oracle SQL 终端中运行 SQL 查询时,它工作得很好。谁能
PrepareStatement 是否只能与值一起使用?示例:我可以使用类似 con.prepareStatement(SELECT ? FROM ? WHERE name =?)或者 ? 仅用于值,
我的数据库添加功能出现问题。下面的代码卡在 ExecuteUpdate 语句上,它没有抛出异常,所以我不知道哪里出了问题。 public static boolean addUser(User use
在运行时循环两次,在通过请求查询调用 PrepareStatement 时因 Bad_Access 而崩溃。 所以我检查了所有的 ResultSet 内存并释放了它但是没有想法有什么办法可以解决这个问
虽然我不得不说,我对 Java 还是个新手,但我已经开始掌握它了,而且它非常酷。无论如何,在我的 Netbeans IDE 中,我收到警告 Dereferencing possible null po
我有以下代码在 MySQL 表中插入行: String sqlInsert = "INSERT INTO test_perf_table ( id, name) VALUES ( ?, ?);"; P
我正在编写一个需要与 HSQLDB 连接的 Jbatch 服务,但在某个时候它会抛出 NullPointerException (and some SQLExceptions/PersistenceE
这个问题在这里已经有了答案: JDBC prepareStatement doesn't work (4 个答案) 关闭 7 年前。 所以我试图创建一个未指定的表名和未指定的列,但是,我是 prep
我是一名优秀的程序员,十分优秀!