Package com.ibatis.sqlmap.client

Examples of com.ibatis.sqlmap.client.SqlMapException


            typeHandlerFactory.register(Resources.classForName(javaType), jdbcType, typeHandler);
          } else {
            typeHandlerFactory.register(Resources.classForName(javaType), typeHandler);
          }
        } catch (Exception e) {
          throw new SqlMapException("Error registering occurred.  Cause: " + e, e);
        }
        vars.errorCtx.setMoreInfo(null);
        vars.errorCtx.setObjectId(null);
      }
    });
View Full Code Here


          txManager.setForceCommit("true".equals(attributes.getProperty("commitRequired")));
        } catch (Exception e) {
          if (e instanceof SqlMapException) {
            throw (SqlMapException) e;
          } else {
            throw new SqlMapException("Error initializing TransactionManager.  Could not instantiate TransactionConfig.  Cause: " + e, e);
          }
        }

        vars.client.getDelegate().setTxManager(txManager);
      }
    });
    parser.addNodelet("/sqlMapConfig/transactionManager/property", new Nodelet() {
      public void process(Node node) throws Exception {
        Properties attributes = NodeletUtils.parseAttributes(node, vars.properties);
        String name = attributes.getProperty("name");
        String value = NodeletUtils.parsePropertyTokens(attributes.getProperty("value"), vars.properties);
        vars.txProps.setProperty(name, value);
      }
    });
    parser.addNodelet("/sqlMapConfig/transactionManager/dataSource", new Nodelet() {
      public void process(Node node) throws Exception {
        vars.dsProps = new Properties();
      }
    });
    parser.addNodelet("/sqlMapConfig/transactionManager/dataSource/end()", new Nodelet() {
      public void process(Node node) throws Exception {
        vars.errorCtx.setActivity("configuring the data source");

        Properties attributes = NodeletUtils.parseAttributes(node, vars.properties);

        String type = attributes.getProperty("type");
        type = vars.typeHandlerFactory.resolveAlias(type);

        try {
          vars.errorCtx.setMoreInfo("Check the data source type or class.");
          DataSourceFactory dsFactory = (DataSourceFactory) Resources.instantiate(type);
          vars.errorCtx.setMoreInfo("Check the data source properties or configuration.");
          dsFactory.initialize(vars.dsProps);
          vars.dataSource = dsFactory.getDataSource();
          vars.errorCtx.setMoreInfo(null);
        } catch (Exception e) {
          if (e instanceof SqlMapException) {
            throw (SqlMapException) e;
          } else {
            throw new SqlMapException("Error initializing DataSource.  Could not instantiate DataSourceFactory.  Cause: " + e, e);
          }
        }
      }
    });
    parser.addNodelet("/sqlMapConfig/transactionManager/dataSource/property", new Nodelet() {
View Full Code Here

          reader = Resources.getResourceAsReader(resource);
        } else if (url != null) {
          vars.errorCtx.setResource(url);
          reader = Resources.getUrlAsReader(url);
        } else {
          throw new SqlMapException("The <sqlMap> element requires either a resource or a url attribute.");
        }

        if (vars.sqlMapConv != null) {
          reader = vars.sqlMapConv.convertXml(reader);
        }
View Full Code Here

        ResultObjectFactory rof;
        try {
          rof = (ResultObjectFactory) Resources.instantiate(type);
          vars.delegate.setResultObjectFactory(rof);
        } catch (Exception e) {
          throw new SqlMapException("Error instantiating resultObjectFactory: " + type, e);
        }
      }
    });
    parser.addNodelet("/sqlMapConfig/resultObjectFactory/property", new Nodelet() {
      public void process(Node node) throws Exception {
View Full Code Here

   *
   * @param ms - the mapped statement to add
   */
  public void addMappedStatement(MappedStatement ms) {
    if (mappedStatements.containsKey(ms.getId())) {
      throw new SqlMapException("There is already a statement named " + ms.getId() + " in this SqlMap.");
    }
    ms.setBaseCacheKey(hashCode());
    mappedStatements.put(ms.getId(), ms);
  }
View Full Code Here

   * @return - the mapped statement
   */
  public MappedStatement getMappedStatement(String id) {
    MappedStatement ms = (MappedStatement) mappedStatements.get(id);
    if (ms == null) {
      throw new SqlMapException("There is no statement named " + id + " in this SqlMap.");
    }
    return ms;
  }
View Full Code Here

   * @return - the cache model
   */
  public CacheModel getCacheModel(String id) {
    CacheModel model = (CacheModel) cacheModels.get(id);
    if (model == null) {
      throw new SqlMapException("There is no cache model named " + id + " in this SqlMap.");
    }
    return model;
  }
View Full Code Here

   * @return - the result map
   */
  public ResultMap getResultMap(String id) {
    ResultMap map = (ResultMap) resultMaps.get(id);
    if (map == null) {
      throw new SqlMapException("There is no result map named " + id + " in this SqlMap.");
    }
    return map;
  }
View Full Code Here

   * @return - the parameter map
   */
  public ParameterMap getParameterMap(String id) {
    ParameterMap map = (ParameterMap) parameterMaps.get(id);
    if (map == null) {
      throw new SqlMapException("There is no parameter map named " + id + " in this SqlMap.");
    }
    return map;
  }
View Full Code Here

    }
  }

  public void setDiscriminator (Discriminator discriminator) {
    if (this.discriminator != null) {
      throw new SqlMapException ("A discriminator may only be set once per result map.");
    }
    this.discriminator = discriminator;
  }
View Full Code Here

TOP

Related Classes of com.ibatis.sqlmap.client.SqlMapException

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.