Examples of CallableStatement


Examples of java.sql.CallableStatement

      }
   }

   public void forceTableChangeCheck() throws Exception {
      Connection conn = null;
      CallableStatement st = null;
      try {
         String sql = "{? = call " + this.replPrefix + "check_structure()}";
         conn = this.dbPool.reserve();
         conn.setAutoCommit(true);
         st = conn.prepareCall(sql);
         st.registerOutParameter(1, Types.VARCHAR);
         st.executeQuery();
      }
      catch (Exception ex) {
         conn = removeFromPool(conn, ROLLBACK_NO);
      }
      finally {
         try {
            if (st != null)
               st.close();
         } catch (Exception ex) {
            ex.printStackTrace();
         }
         conn = releaseIntoPool(conn, COMMIT_NO);
      }
View Full Code Here

Examples of java.sql.CallableStatement

            log.info("table '" + tableName + "' is already registered, will add directly an entry in the ENTRIES Table");
            String destAttrName = "?";
            if (destinations == null || destinations.length == 0)
               destAttrName = "NULL";
            String sql = "{? = call " + this.replPrefix + "check_tables(NULL,?,?,?," + destAttrName + ")}"; // name text, content text)
            CallableStatement st = conn.prepareCall(sql);
            st.setString(2, schema);
            st.setString(3, tableName);
            st.setString(4, ReplicationConstants.CREATE_ACTION);
            if (destinations != null && destinations.length != 0) {
               String post = "</desc>";
               if (forceSend)
                  post = "<attr id='_forceSend'>true</attr>" + post;
               String destinationTxt = "<desc><attr id='_destination'>" + toString(destinations) + "</attr>" + post;
               st.setString(5, destinationTxt);
            }
            st.registerOutParameter(1, Types.VARCHAR);
            st.executeQuery();
            st.close();
            return false;
         }
         /*
         if (force) {
            if (isTableRegistered(conn, tableToWatch)) {
View Full Code Here

Examples of java.sql.CallableStatement

      Connection conn = this.dbPool.reserve();
      byte[] response = null;
      try {
         conn.setAutoCommit(false);
         if (this.isInMaster) {
            CallableStatement st = null;
            try {
               StringBuffer buf = new StringBuffer();
               // buf.append("<desc>\n");
               buf.append("<attr id='").append(ReplicationConstants.STATEMENT_ATTR).append("'>").append(sql).append("</attr>\n");
               buf.append("<attr id='").append(ReplicationConstants.STATEMENT_PRIO_ATTR).append("'>").append(isHighPrio).append("</attr>\n");
               buf.append("<attr id='").append(ReplicationConstants.MAX_ENTRIES_ATTR).append("'>").append(maxResponseEntries).append("</attr>\n");
               buf.append("<attr id='").append(ReplicationConstants.STATEMENT_ID_ATTR).append("'>").append(statementId).append("</attr>\n");
               buf.append("<attr id='").append(ReplicationConstants.SQL_TOPIC_ATTR).append("'>").append(sqlTopic).append("</attr>\n");
               // buf.append("</desc>\n");
              
               String sqlTxt = "{? = call " + this.replPrefix + "prepare_broadcast(?)}";
               st = conn.prepareCall(sqlTxt);
               String value = buf.toString();
               st.setString(2, value);
               st.registerOutParameter(1, Types.VARCHAR);
               st.executeQuery();
            }
            finally {
               st.close();
            }
         }
        
         Statement st2 = conn.createStatement();
         try {
View Full Code Here

Examples of java.sql.CallableStatement

    * @see org.xmlBlaster.contrib.db.I_DbCreateInterceptor#onCreateConnection(java.sql.Connection)
    */
   public void onCreateConnection(Connection conn) throws Exception {
         try {
            String sql = getSql(conn);
            CallableStatement st = conn.prepareCall(sql);
            st.setString(1, identifier);
            st.executeQuery();
         }
         catch (Exception ex) {
            ex.printStackTrace();
         }
   }
View Full Code Here

Examples of java.sql.CallableStatement

    * @param conn The database connection to use.
    * @param event the name of the even on which to wait
    * @param timeout the maximum time to wait in ms
    */
   public static void waitForEvent(Connection conn, String event, long timeout) throws Exception {
      CallableStatement st = null;
      try {
         String sql = "{call dbms_alert.waitone(?,?,?,?)}";
         st = conn.prepareCall(sql);
         st.setString(1, event);
         st.setLong(4, timeout / 1000L);
         st.registerOutParameter(2, Types.VARCHAR);
         st.registerOutParameter(3, Types.INTEGER);
         st.executeQuery();
      }
      finally {
         if (st != null)
            st.close();
      }
   }
View Full Code Here

Examples of java.sql.CallableStatement

    * @param conn the database connection to use.
    * @param event the name of the even on which to wait
    * @param doRegister if true it will register, otherwise unregister.
    */
   private static void registerUnregisterForEvents(Connection conn, String event, boolean doRegister) throws Exception {
      CallableStatement st = null;
      String sql = null;
      if (doRegister)
         sql = "{call dbms_alert.register(?)}";
      else
         sql = "{call dbms_alert.remove(?)}";
      try {
         st = conn.prepareCall(sql);
         st.setString(1, event);
         st.executeQuery();
      }
      finally {
         if (st != null)
            st.close();
      }
   }
View Full Code Here

Examples of java.sql.CallableStatement

      if (map == null)
         return true;
      String sqlCode = (String)map.get(completeTableName);
      if (sqlCode == null)
         return true;
      CallableStatement cs = null;
      try {
         log.fine("Invoking '" + sqlCode + "'");
         cs = conn.prepareCall(sqlCode);
         cs.executeQuery();
      }
      catch (SQLException ex) {
         log.severe("An Exception occured when executing '" + sqlCode + "':" + ex.getMessage());
         ex.printStackTrace();
      }
      finally {
         if (cs != null) {
            try {
               cs.close();
            }
            catch (SQLException ex) {
               ex.printStackTrace();
            }
         }
View Full Code Here

Examples of java.sql.CallableStatement

         Connection conn, int timeout) throws SQLException, IOException {
      checkSameStore(store, meat);
      if (increment == 0)
         return;
      if (true && incRefCounterFunction != null && incRefCounterInvoke != null) {
         CallableStatement st = null;
         try {
            st = conn.prepareCall(incRefCounterInvoke);
            st.setLong(1, meat.getId());
            st.setLong(2, store.getId());
            st.setLong(3, increment);
            st.executeUpdate();
         } finally {
            if (st != null)
               st.close();
         }
      } else {
         XBMeat meatRet = get(store, meat.getId(), conn, timeout);
         meatRet.setRefCount(meatRet.getRefCount() + increment);
         updateRefCounters(store, meatRet, conn, timeout);
View Full Code Here

Examples of java.sql.CallableStatement

  public boolean load(JDCConnection oConn, Object aPK[]) throws SQLException {
    // Rutina especial de carga con procedimiento almacenado para maxima velocidad en el rendering

    ResultSet oRSet;
    PreparedStatement oStmt;
    CallableStatement oCall;
    String sNmPageSet;
    Object sField;
    boolean bRetVal;

    if (DebugFile.trace) {
      DebugFile.writeln("Begin PageSetDB.load([Connection], {" + aPK[0] + "}");
      DebugFile.incIdent();
    }

    if (oConn.getDataBaseProduct()==JDCConnection.DBMS_ORACLE ||
        oConn.getDataBaseProduct()==JDCConnection.DBMS_MSSQL ||
        oConn.getDataBaseProduct()==JDCConnection.DBMS_MYSQL ) {

      if (DebugFile.trace)
        DebugFile.writeln("Connection.prepareCall({ call k_sp_read_pageset ('" + aPK[0] + "',?,?,?,?,?,?,?,?,?,?,?,?,?) }");

      oCall = oConn.prepareCall("{ call k_sp_read_pageset (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) }");

      clear();

      oCall.setObject(1, aPK[0], Types.CHAR);       // gu_pageset
      oCall.registerOutParameter(2, Types.CHAR);    // gu_microsite
      oCall.registerOutParameter(3, Types.VARCHAR); // nm_microsite
      oCall.registerOutParameter(4, Types.CHAR);    // gu_workarea
      oCall.registerOutParameter(5, Types.VARCHAR); // nm_pageset
      oCall.registerOutParameter(6, Types.VARCHAR); // vs_stamp
      oCall.registerOutParameter(7, Types.CHAR); // id_language
      oCall.registerOutParameter(8, Types.TIMESTAMP); // dt_modified
      oCall.registerOutParameter(9, Types.VARCHAR); // path_data
      oCall.registerOutParameter(10, Types.VARCHAR); // id_status
      oCall.registerOutParameter(11, Types.VARCHAR); // path_metadata
      oCall.registerOutParameter(12, Types.VARCHAR); // tx_comments
      oCall.registerOutParameter(13, Types.CHAR);    // gu_company
      oCall.registerOutParameter(14, Types.CHAR);    // gu_project
      oCall.registerOutParameter(15, Types.VARCHAR); // tx_email_from
      oCall.registerOutParameter(16, Types.VARCHAR); // tx_email_reply
      oCall.registerOutParameter(17, Types.VARCHAR); // nm_from
      oCall.registerOutParameter(18, Types.VARCHAR); // tx_subject

      if (DebugFile.trace) DebugFile.writeln("CallableStatement.execute()");

      oCall.execute();

      sNmPageSet = oCall.getString(5);
      bRetVal = (null!=sNmPageSet);

      put (DB.gu_pageset, aPK[0]);

      if (bRetVal) {
        put (DB.gu_microsite, oCall.getString(2).trim());
        put (DB.nm_microsite, oCall.getString(3));
        put (DB.gu_workarea, oCall.getString(4).trim());
        put (DB.nm_pageset, oCall.getString(5));

        sField = oCall.getObject(6);
        if (!oCall.wasNull()) put(DB.vs_stamp, (String) sField);

        sField = oCall.getObject(7);
        if (!oCall.wasNull()) put(DB.id_language, ((String) sField).trim());

        sField = oCall.getObject(8);
        if (!oCall.wasNull()) put(DB.dt_modified, oCall.getDate(8));

        sField = oCall.getObject(9);
        if (!oCall.wasNull()) put(DB.path_data, (String) sField);

        sField = oCall.getObject(10);
        if (!oCall.wasNull()) put(DB.id_status, (String) sField);

        sField = oCall.getObject(11);
        if (!oCall.wasNull()) put(DB.path_metadata, (String) sField);

        sField = oCall.getObject(12);
        if (!oCall.wasNull()) put(DB.tx_comments, (String) sField);

        sField = oCall.getObject(13);
        if (!oCall.wasNull()) put(DB.gu_company, sField.toString().trim());

        sField = oCall.getObject(14);
        if (!oCall.wasNull()) put(DB.gu_project, sField.toString().trim());

        sField = oCall.getObject(15);
        if (!oCall.wasNull()) put(DB.tx_email_from, sField.toString().trim());

        sField = oCall.getObject(16);
        if (!oCall.wasNull()) put(DB.tx_email_reply, sField.toString().trim());

        sField = oCall.getObject(17);
        if (!oCall.wasNull()) put(DB.nm_from, sField.toString().trim());

        sField = oCall.getObject(18);
        if (!oCall.wasNull()) put(DB.tx_subject, sField.toString().trim());
      } // fi (bRetVal)

      oCall.close();
    }
    else {

      if (DebugFile.trace)
        DebugFile.writeln("Connection.prepareStatement(SELECT m." + DB.gu_microsite + ",m." + DB.nm_microsite +
View Full Code Here

Examples of java.sql.CallableStatement

  // ----------------------------------------------------------

  protected void execCommands(String sTime, int iTable, Object PK[], int cParams)
      throws SQLException,NullPointerException {
    // Ejecuta los comandos <INIT>, <TERM>, <BEFORE> o <AFTER> definidos para este DataStruct
    CallableStatement oCall;
    Statement oStmt;
    ResultSet rCount;
    int cAffected;
    String sSQL;
    String sTable;
    ListIterator oIter;

    if (DebugFile.trace) {
      if (iTable!=-1)
        sTable = getRowSet(iTable).OriginTable;
      else
        sTable = "";
      DebugFile.writeln ("Begin DataStruct.execCommands(" +  sTime + ", " + sTable + ", ..., " + String.valueOf(cParams) + ")");
      DebugFile.incIdent();
    }

    // Seleccionar el iterador para la lista adecudada de comandos
    if (-1==iTable) {
      if (sTime.equals("INIT")) {
        if (null==InitStmts)
          throw new NullPointerException("DataStruct.execCommands() InitStmts list not initialized");
        oIter = InitStmts.listIterator();
      } else {
        if (null==TermStmts)
          throw new NullPointerException("DataStruct.execCommands() TermStmts list not initialized");
        oIter = TermStmts.listIterator();
      }
    }
    else {
      if (sTime.equals("BEFORE"))
        oIter = ((LinkedList)Before.get(iTable)).listIterator();
      else
        oIter = ((LinkedList)After.get(iTable)).listIterator();
    }

    while (oIter.hasNext()) {
      sSQL = oIter.next().toString();

      // Si el SQL empieza por "{" entonces se ejecuta como un procedimiento almacenado
      if (sSQL.startsWith("{") || sSQL.startsWith("k_sp")) {
        if (DebugFile.trace) DebugFile.writeln ("Connection.prepareCall(" + sSQL + ")");
        oCall = oTrConn.prepareCall(sSQL);
        for (int p=0; p<cParams; p++) {
          if (DebugFile.trace) DebugFile.writeln ("CallableStatement.setObject(" + String.valueOf(p+1) + "," + PK[p].toString() + ")");
          oCall.setObject(p+1, PK[p]);
        } // next (p)
        if (DebugFile.trace) DebugFile.writeln ("Connection.execute(" + sSQL + ")");
        oCall.execute();
        oCall.close();
        oCall = null;
      }
      // Si el SQL NO empieza por "{" entonces se ejecuta como un comando sin ResultSet de vuelta
      else {
        oStmt = oTrConn.createStatement();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.