Package com.esri.gpt.framework.sql

Examples of com.esri.gpt.framework.sql.ManagedConnection


   * @return the registered URL for the remote repository
   * @throws SQLException if an exception occurs
   */
  public String queryCswUrl(RequestContext context, String rid) throws SQLException {
    PreparedStatement st = null;
    ManagedConnection mcon = null;
    rid = Val.chkStr(rid);
    if (rid.length() > 0) {
      try {
        int nId = -1;
        String field = "UUID";
        try {
          nId = Integer.parseInt(rid);
          field = "ID";    
        } catch (NumberFormatException nfe) {}
       
        String table = context.getCatalogConfiguration().getResourceTableName();
        String sql = "SELECT PROTOCOL_TYPE,HOST_URL FROM "+table+" WHERE "+field+"=?";
        mcon = context.getConnectionBroker().returnConnection("");
        st = mcon.getJdbcConnection().prepareStatement(sql);
        if (field.equalsIgnoreCase("ID")) {
          st.setInt(1,nId);
        } else {
          st.setString(1,rid);
        }
View Full Code Here


    if (sbWhere.length() > 0) {
      sbSql.append(" WHERE ").append(sbWhere.toString());
    }

    // establish the connection
    ManagedConnection mc = returnConnection();
    Connection con = mc.getJdbcConnection();

    // prepare the statements
    int n = 0;
    st = con.prepareStatement(sbSql.toString());
View Full Code Here

    sbUpdateSql.append("VALIDATED_COUNT=?,PUBLISHED_COUNT=? ");
    sbUpdateSql.append("WHERE UPPER(UUID)=?");


    // establish the connection
    ManagedConnection mc = returnConnection();
    Connection con = mc.getJdbcConnection();
   
    stInsert = con.prepareStatement(sbInsertSql.toString());
    stUpdate = con.prepareStatement(sbUpdateSql.toString());
   
    PreparedStatement st = null;
View Full Code Here

        getHarvestingHistoryTableName() + " ");
      sbHistoryDeleteSql.append("where UUID in (" +
        sbUuids.toString() + ")");

      // establish the connection
      ManagedConnection mc = returnConnection();
      Connection con = mc.getJdbcConnection();

      stHistoryDelete = con.prepareStatement(sbHistoryDeleteSql.toString());

      logExpression(stHistoryDelete.toString());
View Full Code Here

      sbSql.append("SELECT A.HARVEST_REPORT");
      sbSql.append(" FROM ").append(getHarvestingHistoryTableName()).append(" A ");
      sbSql.append(" WHERE UPPER(A.UUID)=?");

      // establish the connection
      ManagedConnection mc = returnConnection();
      Connection con = mc.getJdbcConnection();

      st = con.prepareStatement(sbSql.toString());
      st.setString(1, record.getUuid().toUpperCase());

      // execute the query
      logExpression(sbSql.toString());
      ResultSet rs = st.executeQuery();

      if (rs.next()) {
        IClobMutator cm = mc.getClobMutator();
        InputStream in = null;
        try {
          in = cm.getStream(rs, 1);
          template.transform(new StreamSource(in), new StreamResult(writer), mapParams);
        } finally {
View Full Code Here

    throw new SearchException("Could not get a Connection Broker so as"
        + " to make a" + " connection to the repository.");
  }

 
  ManagedConnection managedConnection = connectionBroker.returnConnection("");
  Connection connection = managedConnection.getJdbcConnection();
  if (connection == null) {
    throw new SearchException("Got null connection to repository "
        + "for save search");
  }
View Full Code Here

public Map<String, HrRecord> readHarvestRecords(StringSet rids,
    RequestContext context) throws SearchException {
  // TODO: Sort out exception issues
  HrRecord record = null;
  PreparedStatement st = null;
  ManagedConnection mcon = null;
  ResultSet rs = null;
  Map<String, HrRecord> mpRidRecords = new
    TreeMap<String, HrRecord>(String.CASE_INSENSITIVE_ORDER)
  Map<String, String> idFields = new
    TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);

  for (String rid : rids) {
    rid = Val.chkStr(rid);
    if (rid.length() < 1) {
      continue;
    }

    String field = "DOCUUID";
    try {
      Integer.parseInt(rid);
      field = "ID";
    } catch (NumberFormatException nfe) {
      if (!UuidUtil.isUuid(rid)) {
        rid = rid.toUpperCase();
        field = "UPPER(TITLE)";
      }
    }
    idFields.put(rid, field);
  }

  // Create sql to query db
  String table = context.getCatalogConfiguration().getResourceTableName();
  String sql = "SELECT PROTOCOL_TYPE, HOST_URL, PROTOCOL, TITLE, " +
      "DOCUUID, ID FROM "
      + table + " WHERE ";
 
  int i = 0;
  int maxEntries = idFields.size();
 
 
  for (Map.Entry<String, String> entry : idFields.entrySet()) {
    sql += entry.getValue() + "= ?";
    if (i >= 0 && i < maxEntries - 1) {
      sql += " or ";
    }
    i++;

  }
 
  sql += " AND ((APPROVALSTATUS = 'approved') OR (APPROVALSTATUS = 'reviewed'))";
  sql += " AND SEARCHABLE = 'true'";

  LOG.info("DB Query " + sql);
  ArrayList<HrRecord> arrHrRecords = new ArrayList<HrRecord>();
  try {
    mcon = context.getConnectionBroker().returnConnection("");
    st = mcon.getJdbcConnection().prepareStatement(sql);
    int parNum = 1;
    for (Map.Entry<String, String> entry : idFields.entrySet()) {
      String field = entry.getValue();
      String rid = entry.getKey();
      if (field.equalsIgnoreCase("ID")) {
View Full Code Here

* @throws java.sql.SQLException if error accesing database occured
*/
public boolean execute() throws SQLException {

    // establish the connection
  ManagedConnection mc = returnConnection();
  Connection con = mc.getJdbcConnection();

  HjRecord record = read(con);
  if (record!=null) {
    insertCompleted(con, record);
  }
View Full Code Here

  Date currentDate = new Date();

  try {

    // establish the connection
    ManagedConnection mc = returnConnection();
    con = mc.getJdbcConnection();

    StringBuffer sbStmt = new StringBuffer();

    // insert sql
    sbStmt.append("INSERT INTO " + getHarvestingJobsCompletedTableName());
View Full Code Here

  PreparedStatement st = null;

  try {

    // establish the connection
    ManagedConnection mc = returnConnection();
    con = mc.getJdbcConnection();

    StringBuffer sbStmt = new StringBuffer();

    // update sql
    sbStmt.append("DELETE FROM " + getHarvestingJobsPendingTableName());
View Full Code Here

TOP

Related Classes of com.esri.gpt.framework.sql.ManagedConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.