use of com.palantir.nexus.db.sql.SqlConnection 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);
}
}
use of com.palantir.nexus.db.sql.SqlConnection in project atlasdb by palantir.
the class OracleTableNameMapperTest method setup.
@Before
public void setup() {
connectionSupplier = mock(ConnectionSupplier.class);
oracleTableNameMapper = new OracleTableNameMapper();
SqlConnection sqlConnection = mock(SqlConnection.class);
when(connectionSupplier.get()).thenReturn(sqlConnection);
resultSet = mock(AgnosticResultSet.class);
when(sqlConnection.selectResultSetUnregisteredQuery(startsWith("SELECT short_table_name FROM atlasdb_table_names WHERE LOWER(short_table_name)"), anyObject())).thenReturn(resultSet);
}
use of com.palantir.nexus.db.sql.SqlConnection in project atlasdb by palantir.
the class OracleDdlTable method getCompactionConnection.
private SqlConnection getCompactionConnection() {
SqlConnection sqlConnection = conns.get();
try {
int originalNetworkTimeout = sqlConnection.getUnderlyingConnection().getNetworkTimeout();
int newNetworkMillis = Ints.saturatedCast(config.compactionConnectionTimeout());
log.info("Increased sql socket read timeout from {} to {}", SafeArg.of("originalNetworkTimeoutMillis", originalNetworkTimeout), SafeArg.of("newNetworkTimeoutMillis", newNetworkMillis));
sqlConnection.getUnderlyingConnection().setNetworkTimeout(compactionTimeoutExecutor, newNetworkMillis);
} catch (SQLException e) {
log.warn("Failed to increase socket read timeout for the connection. Encountered an exception:", e);
}
return sqlConnection;
}
Aggregations