Search in sources :

Example 6 with AgnosticResultSet

use of com.palantir.nexus.db.sql.AgnosticResultSet in project atlasdb by palantir.

the class TableValueStyleCacheTest method setup.

@Before
public void setup() {
    SqlConnection mockConnection = mock(SqlConnection.class);
    when(connectionSupplier.get()).thenReturn(mockConnection);
    AgnosticResultSet resultSet = mock(AgnosticResultSet.class);
    when(mockConnection.selectResultSetUnregisteredQuery(startsWith("SELECT table_size FROM"), anyObject())).thenReturn(resultSet);
    AgnosticResultRow row = mock(AgnosticResultRow.class);
    when(row.getInteger(eq("table_size"))).thenReturn(TableValueStyle.OVERFLOW.getId());
    doReturn(ImmutableList.of(row)).when(resultSet).rows();
    when(mockConnection.getUnderlyingConnection()).thenReturn(mock(Connection.class));
}
Also used : AgnosticResultSet(com.palantir.nexus.db.sql.AgnosticResultSet) Connection(java.sql.Connection) SqlConnection(com.palantir.nexus.db.sql.SqlConnection) SqlConnection(com.palantir.nexus.db.sql.SqlConnection) AgnosticResultRow(com.palantir.nexus.db.sql.AgnosticResultRow) Before(org.junit.Before)

Example 7 with AgnosticResultSet

use of com.palantir.nexus.db.sql.AgnosticResultSet in project atlasdb by palantir.

the class DbKvsGetRanges method getRowsForBatches.

private static SortedSetMultimap<Integer, byte[]> getRowsForBatches(Supplier<SqlConnection> connectionSupplier, String query, Object[] args) {
    SqlConnection connection = connectionSupplier.get();
    try {
        AgnosticResultSet results = connection.selectResultSetUnregisteredQuery(query, args);
        SortedSetMultimap<Integer, byte[]> ret = TreeMultimap.create(Ordering.natural(), UnsignedBytes.lexicographicalComparator());
        for (AgnosticResultRow row : results.rows()) {
            @SuppressWarnings("deprecation") byte[] rowName = row.getBytes("row_name");
            int batchNum = row.getInteger("batch_num");
            if (rowName != null) {
                ret.put(batchNum, rowName);
            }
        }
        return ret;
    } finally {
        closeSql(connection);
    }
}
Also used : AgnosticResultSet(com.palantir.nexus.db.sql.AgnosticResultSet) SqlConnection(com.palantir.nexus.db.sql.SqlConnection) AgnosticResultRow(com.palantir.nexus.db.sql.AgnosticResultRow)

Example 8 with AgnosticResultSet

use of com.palantir.nexus.db.sql.AgnosticResultSet in project atlasdb by palantir.

the class OracleDdlTable method checkDatabaseVersion.

@Override
public void checkDatabaseVersion() {
    AgnosticResultSet result = conns.get().selectResultSetUnregisteredQuery("SELECT version FROM product_component_version where lower(product) like '%oracle%'");
    String version = result.get(0).getString("version");
    if (VersionStrings.compareVersions(version, MIN_ORACLE_VERSION) < 0) {
        log.error("Your key value service currently uses version {}" + " of oracle. The minimum supported version is {}" + ". If you absolutely need to use an older version of oracle," + " please contact Palantir support for assistance.", version, MIN_ORACLE_VERSION);
    }
}
Also used : AgnosticResultSet(com.palantir.nexus.db.sql.AgnosticResultSet)

Example 9 with AgnosticResultSet

use of com.palantir.nexus.db.sql.AgnosticResultSet in project atlasdb by palantir.

the class PostgresDdlTable method checkDatabaseVersion.

@Override
public void checkDatabaseVersion() {
    AgnosticResultSet result = conns.get().selectResultSetUnregisteredQuery("SHOW server_version");
    String version = result.get(0).getString("server_version");
    PostgresVersionCheck.checkDatabaseVersion(version, log);
}
Also used : AgnosticResultSet(com.palantir.nexus.db.sql.AgnosticResultSet)

Aggregations

AgnosticResultSet (com.palantir.nexus.db.sql.AgnosticResultSet)9 AgnosticResultRow (com.palantir.nexus.db.sql.AgnosticResultRow)5 SqlConnection (com.palantir.nexus.db.sql.SqlConnection)4 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)2 ExecutionException (java.util.concurrent.ExecutionException)2 TableMappingNotFoundException (com.palantir.atlasdb.keyvalue.impl.TableMappingNotFoundException)1 Connection (java.sql.Connection)1 Before (org.junit.Before)1