Java Code Examples for org.skife.jdbi.v2.Handle#getConnection()
The following examples show how to use
org.skife.jdbi.v2.Handle#getConnection() .
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 File: PostgresStorageTest.java From cassandra-reaper with Apache License 2.0 | 6 votes |
@Before public void setUp() throws SQLException, IOException { Server.createTcpServer().start(); DBI dbi = new DBI(DB_URL); Handle handle = dbi.open(); Connection conn = handle.getConnection(); // to suppress output of ScriptRunner PrintStream tmp = new PrintStream(new OutputStream() { @Override public void write(int buff) throws IOException { // do nothing } }); PrintStream console = System.out; System.setOut(tmp); String cwd = Paths.get("").toAbsolutePath().toString(); String path = cwd + "/../src/test/resources/db/postgres/V17_0_0__multi_instance.sql"; ScriptRunner scriptExecutor = new ScriptRunner(conn, false, true); Reader reader = new BufferedReader(new FileReader(path)); scriptExecutor.runScript(reader); System.setOut(console); }
Example 2
Source File: DatabaseShardManager.java From presto with Apache License 2.0 | 5 votes |
private static void insertShardsAndIndex(long tableId, List<ColumnInfo> columns, Collection<ShardInfo> shards, Map<String, Integer> nodeIds, Handle handle) throws SQLException { if (shards.isEmpty()) { return; } boolean bucketed = shards.iterator().next().getBucketNumber().isPresent(); Connection connection = handle.getConnection(); try (IndexInserter indexInserter = new IndexInserter(connection, tableId, columns)) { for (List<ShardInfo> batch : partition(shards, batchSize(connection))) { List<Long> shardIds = insertShards(connection, tableId, batch); if (!bucketed) { insertShardNodes(connection, nodeIds, shardIds, batch); } for (int i = 0; i < batch.size(); i++) { ShardInfo shard = batch.get(i); Set<Integer> shardNodes = shard.getNodeIdentifiers().stream() .map(nodeIds::get) .collect(toSet()); indexInserter.insert( shardIds.get(i), shard.getShardUuid(), shard.getBucketNumber(), shardNodes, shard.getColumnStats()); } indexInserter.execute(); } } }
Example 3
Source File: UpgradeVersion31Test.java From syndesis with Apache License 2.0 | 5 votes |
@Override public Set<String> withHandle(final Handle handle) throws Exception { try (Connection con = handle.getConnection()) { final DatabaseMetaData metaData = con.getMetaData(); try (ResultSet rs = metaData.getIndexInfo(con.getCatalog(), con.getSchema(), "JSONDB", false, false)) { final Set<String> indexes = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); while (rs.next()) { final String indexName = rs.getString("INDEX_NAME"); indexes.add(indexName); } return indexes; } } }