protected PreparedStatement getExistQuery(Connection conn, DatabaseObjectType type) throws SQLException { PreparedStatement pstmt = null; for (SQLObject existQuery : catalogStore.getExistQueries()) { if (type.equals(existQuery.getType())) { pstmt = conn.prepareStatement(existQuery.getSql()); break; } } return pstmt; }
protected void validateSQLObject(List<SQLObject> queries, SQLObject testQuery) { int occurredCount = 0; for (SQLObject query : queries) { if (query.getType() == testQuery.getType()) { occurredCount++; } } if (occurredCount > 1) { throw new TajoInternalError( "Duplicate Query type (" + testQuery.getType() + ") has found."); } }
protected String getDropSQL(DatabaseObjectType type, String name) { SQLObject foundDropQuery = null; String sqlStatement = "DROP " + type.toString() + " " + name; for (SQLObject dropQuery : catalogStore.getDropStatements()) { if (type == dropQuery.getType()) { foundDropQuery = dropQuery; break; } } if (foundDropQuery != null && foundDropQuery.getSql() != null && !foundDropQuery.getSql().isEmpty()) { String dropStatement = foundDropQuery.getSql(); StringBuffer sqlBuffer = new StringBuffer(dropStatement.length() + name.length()); int identifier = dropStatement.indexOf('?'); sqlBuffer .append(dropStatement.substring(0, identifier)) .append(name) .append(dropStatement.substring(identifier + 1)); sqlStatement = sqlBuffer.toString(); } return sqlStatement; }