Package com.ibatis.sqlmap.client

Examples of com.ibatis.sqlmap.client.SqlMapException


    try {
      DocTypeReader xml = new DocTypeReader(reader);
      String docType = xml.getDocType();
      Reader xsl = null;
      if (docType == null) {
        throw new SqlMapException("Could not convert document because DOCTYPE was null.");
      } else {
        if (docType.indexOf("sql-map-config") > -1) {
          xsl = Resources.getResourceAsReader("com/ibatis/db/sqlmap/upgrade/SqlMapConfig.xsl");
        } else if (docType.indexOf("sql-map") > -1) {
          xsl = Resources.getResourceAsReader("com/ibatis/db/sqlmap/upgrade/SqlMap.xsl");
        } else {
          throw new SqlMapException("Could not convert document because DOCTYPE was not recognized: " + docType);
        }
      }
      transformXml(xsl, xml, writer);
    } catch (IOException e) {
      throw new NestedRuntimeException("Error.  Cause: " + e, e);
View Full Code Here


            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

  public Object valueOf(String s) {
    try {
      return format.parse(s);
    } catch (ParseException e) {
      throw new SqlMapException("Error parsing default null value date.  Format must be '" + DATE_FORMAT + "'. Cause: " + e);
    }
  }
View Full Code Here

      SqlMapSessionImpl sqlMapSession = getLocalSqlMapSession();
      sqlMapSession.open();
      sqlMapSession.setUserConnection(conn);
      return sqlMapSession;
    } catch (SQLException e) {
      throw new SqlMapException("Error setting user provided connection.  Cause: " + e, e);
    }
  }
View Full Code Here

  public Object valueOf(String s) {
    try {
      java.util.Date date = format.parse(s);
      return new Time(date.getTime());
    } catch (ParseException e) {
      throw new SqlMapException("Error parsing default null value date.  Format must be '" + DATE_FORMAT + "'. Cause: " + e);
    }
  }
View Full Code Here

  private void validateStatement() {
    try {
      delegate.getMappedStatement(statementName);
    } catch (Exception e) {
      throw new SqlMapException("Invalid bound statement (not found): " + statementName);
    }

    if (StatementType.UNKNOWN == type || StatementType.PROCEDURE == type) {
      throw new SqlMapException("Unkown statement type for statement: " + statementName);
    }
  }
View Full Code Here

//        }
      }
    }
    if (argCount > 1 && type != StatementType.SELECT) {
      // Only select statements can have multiple parameters
      throw new SqlMapException("Too many parameters for statement (must be 1 or 0): " + statementName);
    }
    if (argCount > 1 && type != StatementType.SELECT) {
      // Only select statements can have multiple parameters
      throw new SqlMapException("Too many parameters for statement (must be 1 or 0): " + statementName);
    }
  }
View Full Code Here

  public Object valueOf(String s) {
    try {
      java.util.Date date = format.parse(s);
      return new Date(date.getTime());
    } catch (ParseException e) {
      throw new SqlMapException("Error parsing default null value date.  Format must be '" + DATE_FORMAT + "'. Cause: " + e);
    }
  }
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.