java.sql.Connection
java.sql.Connection是数据库连接接口。
表 1 对java.sql.Connection接口的支持情况
方法名 | 返回值类型 | 支持JDBC 4 |
---|
abort(Executor executor) | void | Yes |
clearWarnings() | void | Yes |
close() | void | Yes |
commit() | void | Yes |
createArrayOf(String typeName, Object[] elements) | Array | Yes |
createBlob() | Blob | Yes |
createClob() | Clob | Yes |
createSQLXML() | SQLXML | Yes |
createStatement() | Statement | Yes |
createStatement(int resultSetType, int resultSetConcurrency) | Statement | Yes |
createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) | Statement | Yes |
getAutoCommit() | Boolean | Yes |
getCatalog() | String | Yes |
getClientInfo() | Properties | Yes |
getClientInfo(String name) | String | Yes |
getHoldability() | int | Yes |
getMetaData() | DatabaseMetaData | Yes |
getNetworkTimeout() | int | Yes |
getSchema() | String | Yes |
getTransactionIsolation() | int | Yes |
getTypeMap() | Map<String,Class<?>> | Yes |
getWarnings() | SQLWarning | Yes |
isClosed() | Boolean | Yes |
isReadOnly() | Boolean | Yes |
isValid(int timeout) | boolean | Yes |
nativeSQL(String sql) | String | Yes |
prepareCall(String sql) | CallableStatement | Yes |
prepareCall(String sql, int resultSetType, int resultSetConcurrency) | CallableStatement | Yes |
prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) | CallableStatement | Yes |
prepareStatement(String sql) | PreparedStatement | Yes |
prepareStatement(String sql, int autoGeneratedKeys) | PreparedStatement | Yes |
prepareStatement(String sql, int[] columnIndexes) | PreparedStatement | Yes |
prepareStatement(String sql, int resultSetType, int resultSetConcurrency) | PreparedStatement | Yes |
prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) | PreparedStatement | Yes |
prepareStatement(String sql, String[] columnNames) | PreparedStatement | Yes |
releaseSavepoint(Savepoint savepoint) | void | Yes |
rollback() | void | Yes |
rollback(Savepoint savepoint) | void | Yes |
setAutoCommit(boolean autoCommit) | void | Yes |
setClientInfo(Properties properties) | void | Yes |
setClientInfo(String name,String value) | void | Yes |
setHoldability(int holdability) | void | Yes |
setNetworkTimeout(Executor executor, int milliseconds) | void | Yes |
setReadOnly(boolean readOnly) | void | Yes |
setSavepoint() | Savepoint | Yes |
setSavepoint(String name) | Savepoint | Yes |
setSchema(String schema) | void | Yes |
setTransactionIsolation(int level) | void | Yes |
setTypeMap(Map<String,Class<?>> map) | void | Yes |
须知:
接口内部默认使用自动提交模式,若通过setAutoCommit(false)关闭自动提交,将会导致后面执行的语句都受到显式事务包裹,数据库中不支持事务中执行的语句不能在此模式下执行。
openGauss 2024-12-21 00:53:16