📄 connection.java
字号:
}
/**
* Is the server configured to use lower-case table names only?
*
* @return true if lower_case_table_names is 'on'
*/
public boolean lowerCaseTableNames() {
return this.lowerCaseTableNames;
}
/**
* A driver may convert the JDBC sql grammar into its system's native SQL
* grammar prior to sending it; nativeSQL returns the native form of the
* statement that the driver would have sent.
*
* @param sql a SQL statement that may contain one or more '?' parameter
* placeholders
*
* @return the native form of this statement
*
* @exception java.sql.SQLException if a database access error occurs
*/
public String nativeSQL(String sql) throws java.sql.SQLException {
if (Driver.TRACE) {
Object[] args = { sql };
Debug.methodCall(this, "nativeSQL", args);
Debug.returnValue(this, "nativeSQL", sql);
}
return EscapeProcessor.escapeSQL(sql,
getIO().versionMeetsMinimum(4, 0, 2));
}
/**
* DOCUMENT ME!
*
* @param sql DOCUMENT ME!
*
* @return DOCUMENT ME!
*
* @throws java.sql.SQLException DOCUMENT ME!
*/
public java.sql.CallableStatement prepareCall(String sql)
throws java.sql.SQLException {
if (this.getUseUltraDevWorkAround()) {
return new UltraDevWorkAround(prepareStatement(sql));
} else {
throw new java.sql.SQLException("Callable statments not "
+ "supported.", "S1C00");
}
}
/**
* JDBC 2.0 Same as prepareCall() above, but allows the default result set
* type and result set concurrency type to be overridden.
*
* @param sql the SQL representing the callable statement
* @param resultSetType a result set type, see ResultSet.TYPE_XXX
* @param resultSetConcurrency a concurrency type, see ResultSet.CONCUR_XXX
*
* @return a new CallableStatement object containing the pre-compiled SQL
* statement
*
* @exception SQLException if a database-access error occurs.
*/
public java.sql.CallableStatement prepareCall(String sql,
int resultSetType, int resultSetConcurrency) throws SQLException {
return prepareCall(sql);
}
/**
* @see Connection#prepareCall(String, int, int, int)
*/
public java.sql.CallableStatement prepareCall(String sql,
int resultSetType, int resultSetConcurrency, int resultSetHoldability)
throws SQLException {
if (this.pedantic) {
if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT) {
throw new SQLException("HOLD_CUSRORS_OVER_COMMIT is only supported holdability level",
SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
}
}
throw new NotImplemented();
}
/**
* A SQL statement with or without IN parameters can be pre-compiled and
* stored in a PreparedStatement object. This object can then be used to
* efficiently execute this statement multiple times.
*
* <p>
* <B>Note:</B> This method is optimized for handling parametric SQL
* statements that benefit from precompilation if the driver supports
* precompilation. In this case, the statement is not sent to the database
* until the PreparedStatement is executed. This has no direct effect on
* users; however it does affect which method throws certain
* java.sql.SQLExceptions
* </p>
*
* <p>
* MySQL does not support precompilation of statements, so they are handled
* by the driver.
* </p>
*
* @param sql a SQL statement that may contain one or more '?' IN parameter
* placeholders
*
* @return a new PreparedStatement object containing the pre-compiled
* statement.
*
* @exception java.sql.SQLException if a database access error occurs.
*/
public java.sql.PreparedStatement prepareStatement(String sql)
throws java.sql.SQLException {
return prepareStatement(sql, java.sql.ResultSet.TYPE_FORWARD_ONLY,
java.sql.ResultSet.CONCUR_READ_ONLY);
}
/**
* JDBC 2.0 Same as prepareStatement() above, but allows the default result
* set type and result set concurrency type to be overridden.
*
* @param sql the SQL query containing place holders
* @param resultSetType a result set type, see ResultSet.TYPE_XXX
* @param resultSetConcurrency a concurrency type, see ResultSet.CONCUR_XXX
*
* @return a new PreparedStatement object containing the pre-compiled SQL
* statement
*
* @exception SQLException if a database-access error occurs.
*/
public synchronized java.sql.PreparedStatement prepareStatement(
String sql, int resultSetType, int resultSetConcurrency)
throws SQLException {
checkClosed();
PreparedStatement pStmt = null;
if (this.cachePreparedStatements) {
PreparedStatement.ParseInfo pStmtInfo = (PreparedStatement.ParseInfo) cachedPreparedStatementParams
.get(sql);
if (pStmtInfo == null) {
pStmt = new com.mysql.jdbc.PreparedStatement(this, sql,
this.database);
PreparedStatement.ParseInfo parseInfo = pStmt.getParseInfo();
if (parseInfo.statementLength < this.preparedStatementCacheMaxSqlSize) {
if (this.cachedPreparedStatementParams.size() >= 25) {
Iterator oldestIter = this.cachedPreparedStatementParams.keySet()
.iterator();
long lruTime = Long.MAX_VALUE;
String oldestSql = null;
while (oldestIter.hasNext()) {
String sqlKey = (String) oldestIter.next();
PreparedStatement.ParseInfo lruInfo = (PreparedStatement.ParseInfo) this.cachedPreparedStatementParams
.get(sqlKey);
if (lruInfo.lastUsed < lruTime) {
lruTime = lruInfo.lastUsed;
oldestSql = sqlKey;
}
}
if (oldestSql != null) {
this.cachedPreparedStatementParams.remove(oldestSql);
}
}
cachedPreparedStatementParams.put(sql, pStmt.getParseInfo());
}
} else {
pStmtInfo.lastUsed = System.currentTimeMillis();
pStmt = new com.mysql.jdbc.PreparedStatement(this, sql,
this.database, pStmtInfo);
}
} else {
pStmt = new com.mysql.jdbc.PreparedStatement(this, sql,
this.database);
}
//
// FIXME: Create warnings if can't create results of the given
// type or concurrency
//
pStmt.setResultSetType(resultSetType);
pStmt.setResultSetConcurrency(resultSetConcurrency);
return pStmt;
}
/**
* @see Connection#prepareStatement(String, int, int, int)
*/
public java.sql.PreparedStatement prepareStatement(String sql,
int resultSetType, int resultSetConcurrency, int resultSetHoldability)
throws SQLException {
if (this.pedantic) {
if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT) {
throw new SQLException("HOLD_CUSRORS_OVER_COMMIT is only supported holdability level",
SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
}
}
return prepareStatement(sql, resultSetType, resultSetConcurrency);
}
/**
* @see Connection#prepareStatement(String, int)
*/
public java.sql.PreparedStatement prepareStatement(String sql,
int autoGenKeyIndex) throws SQLException {
java.sql.PreparedStatement pStmt = prepareStatement(sql);
((com.mysql.jdbc.PreparedStatement) pStmt).setRetrieveGeneratedKeys(autoGenKeyIndex == Statement.RETURN_GENERATED_KEYS);
return pStmt;
}
/**
* @see Connection#prepareStatement(String, int[])
*/
public java.sql.PreparedStatement prepareStatement(String sql,
int[] autoGenKeyIndexes) throws SQLException {
java.sql.PreparedStatement pStmt = prepareStatement(sql);
((com.mysql.jdbc.PreparedStatement) pStmt).setRetrieveGeneratedKeys((autoGenKeyIndexes != null)
&& (autoGenKeyIndexes.length > 0));
return pStmt;
}
/**
* @see Connection#prepareStatement(String, String[])
*/
public java.sql.PreparedStatement prepareStatement(String sql,
String[] autoGenKeyColNames) throws SQLException {
java.sql.PreparedStatement pStmt = prepareStatement(sql);
((com.mysql.jdbc.PreparedStatement) pStmt).setRetrieveGeneratedKeys((autoGenKeyColNames != null)
&& (autoGenKeyColNames.length > 0));
return pStmt;
}
/**
* @see Connection#releaseSavepoint(Savepoint)
*/
public void releaseSavepoint(Savepoint arg0) throws SQLException {
throw new NotImplemented();
}
/**
* The method rollback() drops all changes made since the previous
* commit/rollback and releases any database locks currently held by the
* Connection.
*
* @exception java.sql.SQLException if a database access error occurs
* @throws SQLException DOCUMENT ME!
*
* @see commit
*/
public void rollback() throws java.sql.SQLException {
if (Driver.TRACE) {
Object[] args = new Object[0];
Debug.methodCall(this, "rollback", args);
}
checkClosed();
try {
// no-op if _relaxAutoCommit == true
if (this.autoCommit && !this.relaxAutoCommit) {
throw new SQLException("Can't call rollback when autocommit=true",
SQLError.SQL_STATE_GENERAL_ERROR);
} else if (this.transactionsSupported) {
try {
rollbackNoChecks();
} catch (SQLException sqlEx) {
// We ignore non-transactional tables if told to do so
if (this.ignoreNonTxTables
&& (sqlEx.getErrorCode() != MysqlDefs.ER_WARNING_NOT_COMPLETE_ROLLBACK)) {
throw sqlEx;
}
}
}
} finally {
if (this.reconnectAtTxEnd) {
pingAndReconnect(true);
}
}
}
/**
* @see Connection#rollback(Savepoint)
*/
public void rollback(Savepoint arg0) throws SQLException {
throw new NotImplemented();
}
/**
* Used by MiniAdmin to shutdown a MySQL server
*
* @throws SQLException if the command can not be issued.
*/
public void shutdownServer() throws SQLException {
try {
this.io.sendCommand(MysqlDefs.SHUTDOWN, null, null);
} catch (Exception ex) {
throw new SQLException("Unhandled exception '" + ex.toString()
+ "'", SQLError.SQL_STATE_GENERAL_ERROR);
}
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public boolean supportsIsolationLevel() {
return this.hasIsolationLevels;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public boolean supportsQuotedIdentifiers() {
return this.hasQuotedIdentifiers;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public boolean supportsTransactions() {
return this.transactionsSupported;
}
/**
* Should we use compression?
*
* @return should we use compression to communicate with the server?
*/
public boolean useCompression() {
return this.useCompression;
}
/**
* Returns the paranoidErrorMessages.
*
* @return boolean if we should be paranoid about error messages.
*/
public boolean useParanoidErrorMessages() {
return paranoid;
}
/**
* Should we use SSL?
*
* @return should we use SSL to communicate with the server?
*/
public boolean useSSL() {
return this.useSSL;
}
/**
* Should we enable work-arounds for floating point rounding errors in the
* server?
*
* @return should we use floating point work-arounds?
*/
public boolean useStrictFloatingPoint() {
return this.strictFloatingPoint;
}
/**
* Returns the strictUpdates value.
*
* @return boolean
*/
public boolean useStrictUpdates() {
return strictUpdates;
}
/**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -