示例#1
0
  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;
  }
示例#2
0
  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;
  }