Logo Search packages:      
Sourcecode: mysql-connector-java version File versions  Download package

com::mysql::jdbc::ServerPreparedStatement::ServerPreparedStatement ( ConnectionImpl  conn,
String  sql,
String  catalog,
int  resultSetType,
int  resultSetConcurrency 
) throws SQLException [inline, protected]

Creates a new ServerPreparedStatement object.

Parameters:
conn the connection creating us.
sql the SQL containing the statement to prepare.
catalog the catalog in use when we were created.
Exceptions:
SQLException If an error occurs

Definition at line 345 of file ServerPreparedStatement.java.

References com::mysql::jdbc::StatementImpl::checkNullOrEmptyQuery(), com::mysql::jdbc::StatementImpl::connection, com::mysql::jdbc::PreparedStatement::firstCharOfStmt, com::mysql::jdbc::ConnectionPropertiesImpl::getAutoSlowLog(), com::mysql::jdbc::ConnectionImpl::getStatementComment(), com::mysql::jdbc::PreparedStatement::hasLimitClause, isSelectQuery, com::mysql::jdbc::PreparedStatement::originalSql, com::mysql::jdbc::PreparedStatement::parameterCount, com::mysql::jdbc::PreparedStatement::parameterTypes, realClose(), com::mysql::jdbc::StatementImpl::resultSetConcurrency, com::mysql::jdbc::StatementImpl::resultSetType, com::mysql::jdbc::PreparedStatement::setResultSetConcurrency(), com::mysql::jdbc::PreparedStatement::setResultSetType(), stringTypeCode, com::mysql::jdbc::PreparedStatement::useTrueBoolean, and com::mysql::jdbc::ConnectionImpl::versionMeetsMinimum().

Referenced by getInstance().

                                      {
            super(conn, catalog);

            checkNullOrEmptyQuery(sql);

            int startOfStatement = findStartOfStatement(sql);
            
            this.firstCharOfStmt = StringUtils.firstAlphaCharUc(sql, startOfStatement);
            
            this.isSelectQuery = 'S' == this.firstCharOfStmt;
            
            if (this.connection.versionMeetsMinimum(5, 0, 0)) {
                  this.serverNeedsResetBeforeEachExecution = 
                        !this.connection.versionMeetsMinimum(5, 0, 3);
            } else {
                  this.serverNeedsResetBeforeEachExecution =
                        !this.connection.versionMeetsMinimum(4, 1, 10);
            }
            
            this.useAutoSlowLog = this.connection.getAutoSlowLog();
            this.useTrueBoolean = this.connection.versionMeetsMinimum(3, 21, 23);
            this.hasLimitClause = (StringUtils.indexOfIgnoreCase(sql, "LIMIT") != -1); //$NON-NLS-1$
            
            String statementComment = this.connection.getStatementComment();

            this.originalSql = (statementComment == null) ? sql : "/* "
                        + statementComment + " */ " + sql;

            if (this.connection.versionMeetsMinimum(4, 1, 2)) {
                  this.stringTypeCode = MysqlDefs.FIELD_TYPE_VAR_STRING;
            } else {
                  this.stringTypeCode = MysqlDefs.FIELD_TYPE_STRING;
            }

            try {
                  serverPrepare(sql);
            } catch (SQLException sqlEx) {
                  realClose(false, true);
                  // don't wrap SQLExceptions
                  throw sqlEx;
            } catch (Exception ex) {
                  realClose(false, true);

                  throw SQLError.createSQLException(ex.toString(),
                              SQLError.SQL_STATE_GENERAL_ERROR);
            }
            
            setResultSetType(resultSetType);
            setResultSetConcurrency(resultSetConcurrency);
            
            this.parameterTypes = new int[this.parameterCount];
      }


Generated by  Doxygen 1.6.0   Back to index