List of usage examples for java.sql Connection getSchema
String getSchema() throws SQLException;
Connection
object's current schema name. From source file:org.xenei.bloomgraph.bloom.sql.MySQLCommands.java
/** * Create the page index table./*from w w w . jav a 2s.c om*/ * * @param metadata * the metadata for the database. * @throws SQLException */ private void createPageIndexTable(final DatabaseMetaData metadata) throws SQLException { ResultSet rs = null; Statement stmt = null; final Connection connection = metadata.getConnection(); try { rs = metadata.getTables(connection.getCatalog(), connection.getSchema(), getPageIndexTableName(), new String[] { "TABLE" }); if (!rs.next()) { // table does not exist stmt = connection.createStatement(); stmt.executeUpdate(CREAT_PAGE_INDEX_TABLE_FMT); String stmtStr = String.format(CREATE_PAGE_INDX_TRIGGER, "INSERT"); stmt.executeUpdate(stmtStr); stmtStr = String.format(CREATE_PAGE_INDX_TRIGGER, "UPDATE"); stmt.executeUpdate(stmtStr); } } finally { DbUtils.closeQuietly(rs); DbUtils.closeQuietly(stmt); } }
From source file:org.xenei.bloomgraph.bloom.sql.MySQLCommands.java
/** * Create the page stats table.//w w w . j a v a 2 s .com * * @param metadata * the metadata for the database. * @throws SQLException * on error */ private void createPageStatsTable(final DatabaseMetaData metadata) throws SQLException { ResultSet rs = null; Statement stmt = null; final Connection connection = metadata.getConnection(); try { rs = metadata.getTables(connection.getCatalog(), connection.getSchema(), getPageStatsTableName(), new String[] { "TABLE" }); if (!rs.next()) { stmt = connection.createStatement(); stmt.execute( "CREATE TABLE PageStats ( idx INT PRIMARY KEY, records INT, deletes INT, bytes INT ) ENGINE MyISAM"); } } finally { DbUtils.closeQuietly(rs); DbUtils.closeQuietly(stmt); } }