コード例 #1
0
ファイル: OracleSchemaDAO.java プロジェクト: guylerme/Bench
  private boolean existsIndividualProperty(
      int schemaId,
      String propertyName,
      String propertyValue,
      String className,
      String classValue) {
    Connection con = null;
    try {
      con = factory.getConnection();
    } catch (DataSourceConnectionException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    PreparedStatement pst = null;
    PreparedStatement pstName = null;
    ResultSet rs = null;

    try {
      pst =
          con.prepareStatement(
              "SELECT * FROM INDIVIDUAL_PROPERTY WHERE PROPERTY_SCHEMAID = "
                  + schemaId
                  + " AND PROPERTY_URI = '"
                  + propertyName
                  + "' AND \"VALUE\" = '"
                  + propertyValue
                  + "' AND INDIVIDUAL_CLASS_CLASS_SCHEMAID = "
                  + schemaId
                  + " AND INDIVIDUAL_CLASS_CLASS_URI = '"
                  + className
                  + "' AND INDIVIDUAL_CLASS_CLASS_VALUE = '"
                  + classValue
                  + "';");
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    try {
      rs = pst.executeQuery();

      if (rs.next()) return true;
      else return false;
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return false;
  }
コード例 #2
0
ファイル: OracleSchemaDAO.java プロジェクト: guylerme/Bench
  private long getSchemaNextId() {
    long retorno = 0;

    Connection con = null;
    try {
      con = factory.getConnection();
    } catch (DataSourceConnectionException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    PreparedStatement pst = null;
    ResultSet rs = null;
    SchemaBean schema = null;
    try {
      pst = con.prepareStatement(SQL_GET_SCHEMAID_NEXTVAL);

      rs = pst.executeQuery();
      if (rs.next()) {
        retorno = rs.getInt(1);
      }
    } catch (final SQLException ex) {
      log.error("An error ocurred when trying to get a schema by its name", ex);

    } finally {
      try {
        if (rs != null) {
          rs.close();
        }
        if (pst != null) {
          pst.close();
        }
      } catch (final SQLException ex) {
        log.error("Error trying to close a resultset or a prepared statement", ex);
      }
      rs = null;
      pst = null;
    }

    return retorno;
  }
コード例 #3
0
ファイル: OracleSchemaDAO.java プロジェクト: guylerme/Bench
  private boolean existsIndividualClass(long schemaId, String uri, String value) {
    Connection con = null;
    try {
      con = factory.getConnection();
    } catch (DataSourceConnectionException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    PreparedStatement pst = null;
    PreparedStatement pstName = null;
    ResultSet rs = null;

    try {
      pst =
          con.prepareStatement(
              "SELECT * FROM INDIVIDUAL_CLASS"
                  + " WHERE CLASS_SCHEMAID = "
                  + schemaId
                  + " AND CLASS_URI = '"
                  + uri
                  + "' AND \"VALUE\" = '"
                  + value
                  + "';");
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    try {
      rs = pst.executeQuery();

      if (rs.next()) return true;
      else return false;
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return false;
  }
コード例 #4
0
ファイル: OracleSchemaDAO.java プロジェクト: guylerme/Bench
  private boolean exists(String tableName, long schemaId, String uri) {
    Connection con = null;
    try {
      con = factory.getConnection();
    } catch (DataSourceConnectionException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    PreparedStatement pst = null;
    PreparedStatement pstName = null;
    ResultSet rs = null;

    try {
      pst =
          con.prepareStatement(
              "SELECT * FROM \""
                  + tableName
                  + "\" WHERE SCHEMAID = "
                  + schemaId
                  + " AND URI = '"
                  + uri
                  + "'");
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    try {
      rs = pst.executeQuery();

      if (rs.next()) return true;
      else return false;
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return false;
  }