Java Code Examples for java.sql.PreparedStatement#getResultSetConcurrency()

The following examples show how to use java.sql.PreparedStatement#getResultSetConcurrency() . 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 want to check out the right sidebar which shows the related API usage.
Example 1
@Override
public PreparedStatement prepareStatement(String sql,
                                          int resultSetType,
                                          int resultSetConcurrency,
                                          int resultSetHoldability) throws SQLException {
    PreparedStatement statement = statementCache.get(sql);
    if (statement != null &&
        statement.getResultSetType() == resultSetType &&
        statement.getResultSetConcurrency() == resultSetConcurrency &&
        statement.getResultSetHoldability() == resultSetHoldability) {
        return statement;
    }
    statement = super.prepareStatement(sql, resultSetType,
            resultSetConcurrency, resultSetHoldability);
    return statementCache.put(sql, statement);
}
 
Example 2
Source Project: gemfirexd-oss   File: FromVTI.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Get the ResultSetMetaData for the class/object.  We first look for 
 * the optional static method which has the same signature as the constructor.
 * If it doesn't exist, then we instantiate an object and get the ResultSetMetaData
 * from that object.
 *
 * @return The ResultSetMetaData from the class/object.
 *
 * @exception StandardException		Thrown on error
 */
public ResultSetMetaData getResultSetMetaData() 
	throws StandardException
{
	// Get the actual 
	ResultSetMetaData rsmd = null;

	try
	{	
		if (version2)
		{
			ps = (PreparedStatement) getNewInstance();

			if (ps.getResultSetConcurrency() != ResultSet.CONCUR_UPDATABLE)
			{
				throw StandardException.newException(SQLState.LANG_UPDATABLE_VTI_NON_UPDATABLE_RS, 
													 getVTIName());
			}

			rsmd = ps.getMetaData();

               controlsDeferral = (ps instanceof DeferModification);

               /* See if the result set is known to be insensitive or not.
                *
                * Some older VTI implementations do not implement getResultSetType(). UpdatableVTITemplate
                * does not implement it at all. UpdatableVTITemplate.getResultSetType throws an
                * exception. In either of these cases make the conservative assumption that the result set is sensitive.
                */
               try
               {
                   resultSetType = ps.getResultSetType();
               }
               catch( SQLException sqle){}
               catch( java.lang.AbstractMethodError ame){}
               catch( java.lang.NoSuchMethodError nsme){}
               isInsensitive = (resultSetType == ResultSet.TYPE_SCROLL_INSENSITIVE);

			if (!implementsVTICosting) {
				ps.close();
				ps = null;
			}

		}
		else
		{
			rs = (ResultSet) getNewInstance();

			rsmd = rs.getMetaData();

			if (!implementsVTICosting) {
				rs.close();
				rs = null;
			}
		}
	}
	catch(Throwable t)
	{
		throw StandardException.unexpectedUserException(t);
	}

	return rsmd;
}
 
Example 3
Source Project: gemfirexd-oss   File: FromVTI.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Get the ResultSetMetaData for the class/object.  We first look for 
 * the optional static method which has the same signature as the constructor.
 * If it doesn't exist, then we instantiate an object and get the ResultSetMetaData
 * from that object.
 *
 * @return The ResultSetMetaData from the class/object.
 *
 * @exception StandardException		Thrown on error
 */
public ResultSetMetaData getResultSetMetaData() 
	throws StandardException
{
	// Get the actual 
	ResultSetMetaData rsmd = null;

	try
	{	
		if (version2)
		{
			ps = (PreparedStatement) getNewInstance();

			if (ps.getResultSetConcurrency() != ResultSet.CONCUR_UPDATABLE)
			{
				throw StandardException.newException(SQLState.LANG_UPDATABLE_VTI_NON_UPDATABLE_RS, 
													 getVTIName());
			}

			rsmd = ps.getMetaData();

               controlsDeferral = (ps instanceof DeferModification);

               /* See if the result set is known to be insensitive or not.
                *
                * Some older VTI implementations do not implement getResultSetType(). UpdatableVTITemplate
                * does not implement it at all. UpdatableVTITemplate.getResultSetType throws an
                * exception. In either of these cases make the conservative assumption that the result set is sensitive.
                */
               try
               {
                   resultSetType = ps.getResultSetType();
               }
               catch( SQLException sqle){}
               catch( java.lang.AbstractMethodError ame){}
               catch( java.lang.NoSuchMethodError nsme){}
               isInsensitive = (resultSetType == ResultSet.TYPE_SCROLL_INSENSITIVE);

			if (!implementsVTICosting) {
				ps.close();
				ps = null;
			}

		}
		else
		{
			rs = (ResultSet) getNewInstance();

			rsmd = rs.getMetaData();

			if (!implementsVTICosting) {
				rs.close();
				rs = null;
			}
		}
	}
	catch(Throwable t)
	{
		throw StandardException.unexpectedUserException(t);
	}

	return rsmd;
}
 
Example 4
@Test
public void testPreparedStatementConfig() throws SQLException {
    PreparedStatement preparedStatement = swConnection.prepareStatement("INSERT INTO test VALUES( ? , ?)", 1);
    preparedStatement.setInt(1, 1);
    preparedStatement.setString(2, "a");
    preparedStatement.getUpdateCount();
    preparedStatement.setFetchDirection(1);
    preparedStatement.getFetchDirection();
    preparedStatement.getResultSetConcurrency();
    preparedStatement.getResultSetType();
    preparedStatement.isClosed();
    preparedStatement.setPoolable(false);
    preparedStatement.isPoolable();
    preparedStatement.getWarnings();
    preparedStatement.clearWarnings();
    preparedStatement.setCursorName("test");
    preparedStatement.setMaxFieldSize(11);
    preparedStatement.getMaxFieldSize();
    preparedStatement.setMaxRows(10);
    preparedStatement.getMaxRows();
    preparedStatement.getParameterMetaData();
    preparedStatement.setEscapeProcessing(true);
    preparedStatement.setFetchSize(1);
    preparedStatement.getFetchSize();
    preparedStatement.setQueryTimeout(1);
    preparedStatement.getQueryTimeout();
    Connection connection = preparedStatement.getConnection();

    preparedStatement.execute();

    preparedStatement.getMoreResults();
    preparedStatement.getMoreResults(1);
    preparedStatement.getResultSetHoldability();
    preparedStatement.getMetaData();
    preparedStatement.getResultSet();

    preparedStatement.close();
    verify(mysqlPreparedStatement).getUpdateCount();
    verify(mysqlPreparedStatement).getMoreResults();
    verify(mysqlPreparedStatement).setFetchDirection(anyInt());
    verify(mysqlPreparedStatement).getFetchDirection();
    verify(mysqlPreparedStatement).getResultSetType();
    verify(mysqlPreparedStatement).isClosed();
    verify(mysqlPreparedStatement).setPoolable(anyBoolean());
    verify(mysqlPreparedStatement).getWarnings();
    verify(mysqlPreparedStatement).clearWarnings();
    verify(mysqlPreparedStatement).setCursorName(anyString());
    verify(mysqlPreparedStatement).setMaxFieldSize(anyInt());
    verify(mysqlPreparedStatement).getMaxFieldSize();
    verify(mysqlPreparedStatement).setMaxRows(anyInt());
    verify(mysqlPreparedStatement).getMaxRows();
    verify(mysqlPreparedStatement).setEscapeProcessing(anyBoolean());
    verify(mysqlPreparedStatement).getResultSetConcurrency();
    verify(mysqlPreparedStatement).getResultSetConcurrency();
    verify(mysqlPreparedStatement).getResultSetType();
    verify(mysqlPreparedStatement).getMetaData();
    verify(mysqlPreparedStatement).getParameterMetaData();
    verify(mysqlPreparedStatement).getMoreResults(anyInt());
    verify(mysqlPreparedStatement).setFetchSize(anyInt());
    verify(mysqlPreparedStatement).getFetchSize();
    verify(mysqlPreparedStatement).getQueryTimeout();
    verify(mysqlPreparedStatement).setQueryTimeout(anyInt());
    verify(mysqlPreparedStatement).getResultSet();
    assertThat(connection, CoreMatchers.<Connection>is(swConnection));
}