gpt4 book ai didi

java - createStatement()方法如何返回Statement对象?

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:11:12 27 4
gpt4 key购买 nike

<分区>

根据 javadoc,createStatement() 方法创建一个 Statement 实例,用于将 SQL 语句发送到数据库。

现在 Statementjava.sql 包下的 interface 我的理解是不可能创建接口(interface)的实例在 Java 中。

那它是如何工作的呢?我在源代码中找到了这个,只是我不明白。

/**
* Creates a <code>Statement</code> object for sending
* SQL statements to the database.
* SQL statements without parameters are normally
* executed using <code>Statement</code> objects. If the same SQL statement
* is executed many times, it may be more efficient to use a
* <code>PreparedStatement</code> object.
* <P>
* Result sets created using the returned <code>Statement</code>
* object will by default be type <code>TYPE_FORWARD_ONLY</code>
* and have a concurrency level of <code>CONCUR_READ_ONLY</code>.
* The holdability of the created result sets can be determined by
* calling {@link #getHoldability}.
*
* @return a new default <code>Statement</code> object
* @exception SQLException if a database access error occurs
* or this method is called on a closed connection
*/
Statement createStatement() throws SQLException;

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com