Package javax.resource

Examples of javax.resource.ResourceException


    public boolean execute (InteractionSpec ispec, Record input, Record output)
            throws ResourceException {

        if (ispec == null ||
            (!(ispec instanceof CciInteractionSpec))) {
            throw new ResourceException("Invalid interaction spec");
        }

        String procName = ((CciInteractionSpec)ispec).getFunctionName();
        String schema = ((CciInteractionSpec)ispec).getSchema();
        String catalog = ((CciInteractionSpec)ispec).getCatalog();
View Full Code Here


                while (procNames.next()) {
                    procFound++;
                }
                procNames.close();
                if (procFound == 0) {
                    throw new ResourceException("Cannot find procedure " +
                                                procName +
                                                ". Please check catalog, schema and function name.");
                }

    ResultSet rs =
        metadata.getProcedureColumns(catalog,schema,procName,null);
                List parameterList = new ArrayList();
    boolean function=false;
    while(rs.next()) {            
        if((rs.getShort(5)==DatabaseMetaData.procedureColumnReturn)
      && (!((rs.getString(7)).equals("void")))) {
      function= true;       
        }
        if (rs.getString(7).equals("void")) {
                        continue; // skip extra info from Cloudscape
        }
        parameterList.add(new Parameter( rs.getString(1),
                                                     rs.getString(2),
                                                     rs.getString(3),
                                                     rs.getString(4),
                                                     rs.getShort(5),
                                                     rs.getShort(6),
                                                     rs.getShort(10)));
    }
                rs.close();

                int paramCount = parameterList.size();
    if (function) {
                    paramCount -= 1;
                }
    //if the procedure is parameterless, paramCount = 0
                procName += "(";
                for(int i=0;i<paramCount;i++) {
                    if (i == 0) {
                        procName += "?";
                    } else {
                        procName += ",?";
                    }
                }
                procName += ")";
                String schemaAddOn = "";
                if (schema != null && !schema.equals("")) {
                    schemaAddOn = schema + ".";
                }
    if (function) {
              procName = "? = call " + schemaAddOn + procName;
    } else {
                    procName = "call " + schemaAddOn + procName;
                }
    //System.out.println("procName.."+procName);
    CallableStatement cstmt =
       conn.prepareCall("{"+ procName +"}");
   
    //get all IN parameters and register all OUT parameters
                int count = parameterList.size();
    int recCount = 0;
    IndexedRecord iRec = null;
               
          for (int i=0; i<count; i++) {
                    Parameter parameter = (Parameter) parameterList.get(i);
        if (parameter.isInputColumn()) {
                        if (iRec == null) {
                            if (input instanceof IndexedRecord) {
                                iRec = (IndexedRecord) input;
                            } else {
                                throw new ResourceException("Invalid input record");
                            }
                        }
                        //get value from input record
      cstmt.setObject(i+1, iRec.get(recCount));
      recCount++;
        }
          } 

                IndexedRecord oRec = null;
                for (int i=0; i<count; i++) {
                    Parameter parameter = (Parameter) parameterList.get(i);
                    if (parameter.isOutputColumn()) {
                        if (oRec == null) {
                            if (output instanceof IndexedRecord) {
                                oRec = (IndexedRecord) output;
                            } else {
                                throw new ResourceException("Invalid output record");
                            }
                        }
                        if (parameter.isDecimalNumeric()) {
                            cstmt.registerOutParameter
                                (i+1, parameter.getDataType(),
                                 parameter.getScale());
                        } else {
                            cstmt.registerOutParameter
                                (i+1, parameter.getDataType());
                        }
        }
                }
    cstmt.execute();

          Class[] parameters = new Class[] {int.class};     
    //get the right getXXX() from Mapping.java for the output
          Mapping map = new Mapping();
          for(int i=0; i<count; i++) {
                    Parameter parameter = (Parameter) parameterList.get(i);
              if(parameter.isOutputColumn()) {
            String ans =(String)
          map.get(new Integer(parameter.getDataType()));
      Method method =
          cstmt.getClass().getMethod(ans,parameters);
            Object[] obj = new Object[] {new Integer(i+1)};
            Object o=method.invoke(cstmt,obj)
            if(output instanceof IndexedRecord) {
          oRec = (IndexedRecord)output;
          oRec.add(o);
          //System.out.println("output..."+o.toString());
      }
        }
    } 
          cstmt.close();
    return oRec;
    //  conn.close();
      } catch(SQLException ex) {
          throw new ResourceException(ex.getMessage());   
      } catch (NoSuchMethodException ex) {
          throw new ResourceException(ex.getMessage());   
            } catch (IllegalAccessException ex) {
          throw new ResourceException(ex.getMessage());   
            } catch (InvocationTargetException ex) {
          throw new ResourceException(ex.getMessage());   
            }               
    }
View Full Code Here

    public Record execute (InteractionSpec ispec, Record input)
        throws ResourceException {

        if (ispec == null ||
            (!(ispec instanceof CciInteractionSpec))) {
            throw new ResourceException("Invalid interaction spec");
        }

        String procName = ((CciInteractionSpec)ispec).getFunctionName();
        String schema = ((CciInteractionSpec)ispec).getSchema();
        String catalog = ((CciInteractionSpec)ispec).getCatalog();
View Full Code Here

           java.sql.Connection con =
         ((CciConnection)connection).getManagedConnection().getJdbcConnection();
           SQLWarning sql = con.getWarnings();
           resWarning = new ResourceWarning(sql.getMessage());
       }catch(SQLException e) {
     throw new ResourceException(e.getMessage());
       }
       return resWarning;
    }
View Full Code Here

        try {
            java.sql.Connection con =
          ((CciConnection)connection).getManagedConnection().getJdbcConnection();
            con.clearWarnings();
       }catch(SQLException e) {
     throw new ResourceException(e.getMessage());
       }
    }
View Full Code Here

    public String getEISProductName() throws ResourceException {
        try {
            Connection con = mc.getJdbcConnection();
            return con.getMetaData().getDatabaseProductName();
        } catch (SQLException ex) {
            ResourceException re = new EISSystemException(ex.getMessage());
            re.setLinkedException(ex);
            throw re;
        }
    }
View Full Code Here

    public String getEISProductVersion() throws ResourceException {
        try {
            Connection con = mc.getJdbcConnection();
            return con.getMetaData().getDatabaseProductVersion();
        } catch (SQLException ex) {
            ResourceException re = new EISSystemException(ex.getMessage());
            re.setLinkedException(ex);
            throw re;
        }
    }
View Full Code Here

    public int getMaxConnections() throws ResourceException {
        try {
            Connection con = mc.getJdbcConnection();
            return con.getMetaData().getMaxConnections();
        } catch (SQLException ex) {
            ResourceException re = new EISSystemException(ex.getMessage());
            re.setLinkedException(ex);
            throw re;
        }
    }
View Full Code Here

     */
  private void checkProperties() throws ResourceException {
    // LDAP URL
    if(this.config.getLdapUrl() == null) {
            final String msg = LDAPPlugin.Util.getString("LDAPConnection.urlPropNotFound"); //$NON-NLS-1$
            throw new ResourceException(msg);
    }
    // LDAP Admin User DN
    if(this.config.getLdapAdminUserDN() == null) {
            final String msg = LDAPPlugin.Util.getString("LDAPConnection.adminUserDNPropNotFound"); //$NON-NLS-1$
            throw new ResourceException(msg);
    }
    // LDAP Admin User Password
    if(this.config.getLdapAdminUserPassword() == null) {
            final String msg = LDAPPlugin.Util.getString("LDAPConnection.adminUserPassPropNotFound"); //$NON-NLS-1$
            throw new ResourceException(msg);
    }
  }
View Full Code Here

   
    try {
      initContext = new InitialLdapContext(connenv, null);
    } catch(NamingException ne){
            final String msg = LDAPPlugin.Util.getString("LDAPConnection.directoryNamingError",ne.getExplanation()); //$NON-NLS-1$
      throw new ResourceException(msg);
    }
    LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Successfully obtained initial LDAP context."); //$NON-NLS-1$
    return initContext;
  }
View Full Code Here

TOP

Related Classes of javax.resource.ResourceException

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.