Java Code Examples for com.mysql.cj.jdbc.result.ResultSetInternalMethods

The following examples show how to use com.mysql.cj.jdbc.result.ResultSetInternalMethods. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: quarkus   Source File: JDBCMySQLProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep
List<NativeImageProxyDefinitionBuildItem> registerProxies() {
    List<NativeImageProxyDefinitionBuildItem> proxies = new ArrayList<>();
    proxies.add(new NativeImageProxyDefinitionBuildItem(JdbcConnection.class.getName()));
    proxies.add(new NativeImageProxyDefinitionBuildItem(MysqlConnection.class.getName()));
    proxies.add(new NativeImageProxyDefinitionBuildItem(Statement.class.getName()));
    proxies.add(new NativeImageProxyDefinitionBuildItem(AutoCloseable.class.getName()));
    proxies.add(new NativeImageProxyDefinitionBuildItem(JdbcStatement.class.getName()));
    proxies.add(new NativeImageProxyDefinitionBuildItem(Connection.class.getName()));
    proxies.add(new NativeImageProxyDefinitionBuildItem(ResultSet.class.getName()));
    proxies.add(
            new NativeImageProxyDefinitionBuildItem(JdbcPreparedStatement.class.getName(), JdbcStatement.class.getName()));
    proxies.add(new NativeImageProxyDefinitionBuildItem(JdbcPropertySet.class.getName(), PropertySet.class.getName(),
            Serializable.class.getName()));
    proxies.add(
            new NativeImageProxyDefinitionBuildItem(Resultset.class.getName(), ResultSetInternalMethods.class.getName()));
    proxies.add(new NativeImageProxyDefinitionBuildItem(LoadBalancedConnection.class.getName(),
            JdbcConnection.class.getName()));
    proxies.add(
            new NativeImageProxyDefinitionBuildItem(ReplicationConnection.class.getName(), JdbcConnection.class.getName()));
    proxies.add(
            new NativeImageProxyDefinitionBuildItem(ResultSetInternalMethods.class.getName(),
                    WarningListener.class.getName(), Resultset.class.getName()));
    return proxies;
}
 
Example 2
Source Project: lams   Source File: StatementImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Close any open result sets that have been 'held open'
 */
protected void closeAllOpenResults() throws SQLException {
    JdbcConnection locallyScopedConn = this.connection;

    if (locallyScopedConn == null) {
        return; // already closed
    }

    synchronized (locallyScopedConn.getConnectionMutex()) {
        if (this.openResults != null) {
            for (ResultSetInternalMethods element : this.openResults) {
                try {
                    element.realClose(false);
                } catch (SQLException sqlEx) {
                    AssertionFailedException.shouldNotHappen(sqlEx);
                }
            }

            this.openResults.clear();
        }
    }
}
 
Example 3
Source Project: FoxTelem   Source File: CallableStatement.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the ResultSet that holds the output parameters, or throws an
 * appropriate exception if none exist, or they weren't returned.
 * 
 * @param paramIndex
 *            parameter index
 * 
 * @return the ResultSet that holds the output parameters
 * 
 * @throws SQLException
 *             if no output parameters were defined, or if no output
 *             parameters were returned.
 */
protected ResultSetInternalMethods getOutputParameters(int paramIndex) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        this.outputParamWasNull = false;

        if (paramIndex == 1 && this.callingStoredFunction && this.returnValueParam != null) {
            return this.functionReturnValueResults;
        }

        if (this.outputParameterResults == null) {
            if (this.paramInfo.numberOfParameters() == 0) {
                throw SQLError.createSQLException(Messages.getString("CallableStatement.7"), MysqlErrorNumbers.SQL_STATE_ILLEGAL_ARGUMENT,
                        getExceptionInterceptor());
            }
            throw SQLError.createSQLException(Messages.getString("CallableStatement.8"), MysqlErrorNumbers.SQL_STATE_GENERAL_ERROR,
                    getExceptionInterceptor());
        }

        return this.outputParameterResults;
    }
}
 
Example 4
Source Project: FoxTelem   Source File: StatementImpl.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Close any open result sets that have been 'held open'
 * 
 * @throws SQLException
 *             if an error occurs
 */
protected void closeAllOpenResults() throws SQLException {
    JdbcConnection locallyScopedConn = this.connection;

    if (locallyScopedConn == null) {
        return; // already closed
    }

    synchronized (locallyScopedConn.getConnectionMutex()) {
        if (this.openResults != null) {
            for (ResultSetInternalMethods element : this.openResults) {
                try {
                    element.realClose(false);
                } catch (SQLException sqlEx) {
                    AssertionFailedException.shouldNotHappen(sqlEx);
                }
            }

            this.openResults.clear();
        }
    }
}
 
Example 5
Source Project: lams   Source File: StatementImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void removeOpenResultSet(ResultSetInternalMethods rs) {
    try {
        synchronized (checkClosed().getConnectionMutex()) {
            if (this.openResults != null) {
                this.openResults.remove(rs);
            }

            boolean hasMoreResults = rs.getNextResultset() != null;

            // clear the current results or GGK results
            if (this.results == rs && !hasMoreResults) {
                this.results = null;
            }
            if (this.generatedKeysResults == rs) {
                this.generatedKeysResults = null;
            }

            // trigger closeOnCompletion if:
            // a) the result set removal wasn't triggered internally
            // b) there are no additional results
            if (!this.isImplicitlyClosingResults && !hasMoreResults) {
                checkAndPerformCloseOnCompletionAction();
            }
        }
    } catch (StatementIsClosedException e) {
        // we can't break the interface, having this be no-op in case of error is ok
    }
}
 
Example 6
Source Project: FoxTelem   Source File: CallableStatement.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public BigDecimal getBigDecimal(int parameterIndex) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(parameterIndex);

        BigDecimal retValue = rs.getBigDecimal(mapOutputParameterIndexToRsIndex(parameterIndex));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 7
Source Project: lams   Source File: StatementImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected ResultSetInternalMethods generatePingResultSet() throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        String encoding = this.session.getServerSession().getCharacterSetMetadata();
        int collationIndex = this.session.getServerSession().getMetadataCollationIndex();
        Field[] fields = { new Field(null, "1", collationIndex, encoding, MysqlType.BIGINT, 1) };
        ArrayList<Row> rows = new ArrayList<>();
        byte[] colVal = new byte[] { (byte) '1' };

        rows.add(new ByteArrayRow(new byte[][] { colVal }, getExceptionInterceptor()));

        return this.resultSetFactory.createFromResultsetRows(ResultSet.CONCUR_READ_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE,
                new ResultsetRowsStatic(rows, new DefaultColumnDefinition(fields)));
    }
}
 
Example 8
Source Project: FoxTelem   Source File: CallableStatement.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public float getFloat(String parameterName) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be from ?=

        float retValue = rs.getFloat(fixParameterName(parameterName));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 9
Source Project: FoxTelem   Source File: CallableStatement.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public Object getObject(int parameterIndex, Map<String, Class<?>> map) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(parameterIndex);

        Object retVal = rs.getObject(mapOutputParameterIndexToRsIndex(parameterIndex), map);

        this.outputParamWasNull = rs.wasNull();

        return retVal;
    }
}
 
Example 10
Source Project: FoxTelem   Source File: CallableStatement.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public URL getURL(String parameterName) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be from ?=

        URL retValue = rs.getURL(fixParameterName(parameterName));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 11
Source Project: FoxTelem   Source File: CallableStatement.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public double getDouble(int parameterIndex) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(parameterIndex);

        double retValue = rs.getDouble(mapOutputParameterIndexToRsIndex(parameterIndex));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 12
Source Project: FoxTelem   Source File: CallableStatement.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public Time getTime(int parameterIndex, Calendar cal) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(parameterIndex);

        Time retValue = rs.getTime(mapOutputParameterIndexToRsIndex(parameterIndex), cal);

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 13
Source Project: lams   Source File: CallableStatement.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see java.sql.CallableStatement#getArray(int)
 */
public Array getArray(int i) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(i);

        Array retValue = rs.getArray(mapOutputParameterIndexToRsIndex(i));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 14
Source Project: FoxTelem   Source File: CallableStatement.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public Date getDate(String parameterName, Calendar cal) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be from ?=

        Date retValue = rs.getDate(fixParameterName(parameterName), cal);

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 15
Source Project: FoxTelem   Source File: CallableStatement.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public <T> T getObject(String parameterName, Class<T> type) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be from ?=

        T retValue = ((ResultSetImpl) rs).getObject(fixParameterName(parameterName), type);

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 16
Source Project: lams   Source File: CallableStatement.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param parameterIndex
 * @param scale
 * 
 * @throws SQLException
 * 
 * @see java.sql.CallableStatement#getBigDecimal(int, int)
 * @deprecated
 */
@Deprecated
public BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(parameterIndex);

        BigDecimal retValue = rs.getBigDecimal(mapOutputParameterIndexToRsIndex(parameterIndex), scale);

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 17
Source Project: FoxTelem   Source File: ConnectionImpl.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void initializeResultsMetadataFromCache(String sql, CachedResultSetMetaData cachedMetaData, ResultSetInternalMethods resultSet) throws SQLException {

    if (cachedMetaData == null) {

        // read from results
        cachedMetaData = new CachedResultSetMetaDataImpl();

        // assume that users will use named-based lookups
        resultSet.getColumnDefinition().buildIndexMapping();
        resultSet.initializeWithMetadata();

        if (resultSet instanceof UpdatableResultSet) {
            ((UpdatableResultSet) resultSet).checkUpdatability();
        }

        resultSet.populateCachedMetaData(cachedMetaData);

        this.resultSetMetadataCache.put(sql, cachedMetaData);
    } else {
        resultSet.getColumnDefinition().initializeFrom(cachedMetaData);
        resultSet.initializeWithMetadata();

        if (resultSet instanceof UpdatableResultSet) {
            ((UpdatableResultSet) resultSet).checkUpdatability();
        }
    }
}
 
Example 18
Source Project: lams   Source File: CallableStatement.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see java.sql.CallableStatement#getBlob(int)
 */
public Blob getBlob(int parameterIndex) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(parameterIndex);

        Blob retValue = rs.getBlob(mapOutputParameterIndexToRsIndex(parameterIndex));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 19
Source Project: lams   Source File: CallableStatement.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see java.sql.CallableStatement#getBlob(java.lang.String)
 */
public Blob getBlob(String parameterName) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be from ?=

        Blob retValue = rs.getBlob(fixParameterName(parameterName));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 20
Source Project: FoxTelem   Source File: CallableStatement.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public BigDecimal getBigDecimal(String parameterName) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be from ?=

        BigDecimal retValue = rs.getBigDecimal(fixParameterName(parameterName));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 21
Source Project: lams   Source File: CallableStatement.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see java.sql.CallableStatement#getBoolean(java.lang.String)
 */
public boolean getBoolean(String parameterName) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be from ?=

        boolean retValue = rs.getBoolean(fixParameterName(parameterName));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 22
Source Project: lams   Source File: CallableStatement.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see java.sql.CallableStatement#getByte(int)
 */
public byte getByte(int parameterIndex) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(parameterIndex);

        byte retValue = rs.getByte(mapOutputParameterIndexToRsIndex(parameterIndex));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 23
Source Project: lams   Source File: CallableStatement.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see java.sql.CallableStatement#getByte(java.lang.String)
 */
public byte getByte(String parameterName) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be from ?=

        byte retValue = rs.getByte(fixParameterName(parameterName));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 24
Source Project: FoxTelem   Source File: StatementImpl.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected ResultSetInternalMethods generatePingResultSet() throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        String encoding = this.session.getServerSession().getCharacterSetMetadata();
        int collationIndex = this.session.getServerSession().getMetadataCollationIndex();
        Field[] fields = { new Field(null, "1", collationIndex, encoding, MysqlType.BIGINT, 1) };
        ArrayList<Row> rows = new ArrayList<>();
        byte[] colVal = new byte[] { (byte) '1' };

        rows.add(new ByteArrayRow(new byte[][] { colVal }, getExceptionInterceptor()));

        return this.resultSetFactory.createFromResultsetRows(ResultSet.CONCUR_READ_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE,
                new ResultsetRowsStatic(rows, new DefaultColumnDefinition(fields)));
    }
}
 
Example 25
Source Project: lams   Source File: CallableStatement.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see java.sql.CallableStatement#getBytes(java.lang.String)
 */
public byte[] getBytes(String parameterName) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be from ?=

        byte[] retValue = rs.getBytes(fixParameterName(parameterName));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 26
Source Project: lams   Source File: ConnectionImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Caches CachedResultSetMetaData that has been placed in the cache using
 * the given SQL as a key.
 * 
 * This method is synchronized by the caller on getMutex(), so if
 * calling this method from internal code in the driver, make sure it's
 * synchronized on the mutex that guards communication with the server.
 * 
 * @param sql
 *            the query that the metadata pertains too.
 * @param cachedMetaData
 *            metadata (if it exists) to populate the cache.
 * @param resultSet
 *            the result set to retreive metadata from, or apply to.
 * 
 * @throws SQLException
 */
public void initializeResultsMetadataFromCache(String sql, CachedResultSetMetaData cachedMetaData, ResultSetInternalMethods resultSet) throws SQLException {

    if (cachedMetaData == null) {

        // read from results
        cachedMetaData = new CachedResultSetMetaDataImpl();

        // assume that users will use named-based lookups
        resultSet.getColumnDefinition().buildIndexMapping();
        resultSet.initializeWithMetadata();

        if (resultSet instanceof UpdatableResultSet) {
            ((UpdatableResultSet) resultSet).checkUpdatability();
        }

        resultSet.populateCachedMetaData(cachedMetaData);

        this.resultSetMetadataCache.put(sql, cachedMetaData);
    } else {
        resultSet.getColumnDefinition().initializeFrom(cachedMetaData);
        resultSet.initializeWithMetadata();

        if (resultSet instanceof UpdatableResultSet) {
            ((UpdatableResultSet) resultSet).checkUpdatability();
        }
    }
}
 
Example 27
Source Project: lams   Source File: CallableStatement.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see java.sql.CallableStatement#getDate(int)
 */
public Date getDate(int parameterIndex) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(parameterIndex);

        Date retValue = rs.getDate(mapOutputParameterIndexToRsIndex(parameterIndex));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 28
Source Project: FoxTelem   Source File: CallableStatement.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public byte getByte(String parameterName) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be from ?=

        byte retValue = rs.getByte(fixParameterName(parameterName));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 29
Source Project: lams   Source File: CallableStatement.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see java.sql.CallableStatement#getDate(java.lang.String, java.util.Calendar)
 */
public Date getDate(String parameterName, Calendar cal) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be from ?=

        Date retValue = rs.getDate(fixParameterName(parameterName), cal);

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example 30
Source Project: lams   Source File: CallableStatement.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see java.sql.CallableStatement#getDouble(int)
 */
public double getDouble(int parameterIndex) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(parameterIndex);

        double retValue = rs.getDouble(mapOutputParameterIndexToRsIndex(parameterIndex));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}