Package ch.inftec.ju.db

Examples of ch.inftec.ju.db.JuDbException


        public void execute(IDatabaseConnection conn) {
          try {
            IDataSet  dbDataSet = conn.createDataSet();
            Assertion.assertEquals(flatXmlDataSet, dbDataSet);
          } catch (Exception ex) {
            throw new JuDbException("Couldn't assert DB data", ex);
          }
        }
      });
    }
View Full Code Here


            QueryDataSet tableDataSet = new QueryDataSet(conn);
            tableDataSet.addTable(tableName, String.format("select * from %s order by %s", tableName, orderColumnName));
           
            Assertion.assertEquals(flatXmlDataSet, tableDataSet);
          } catch (Exception ex) {
            throw new JuDbException("Couldn't assert DB data", ex);
          }
        }
      });
    }
View Full Code Here

        this.schemaName = this.connUtil.getMetaDataInfo().getUserName();
      }
      dataTypeFactory = new Oracle10DataTypeFactory();
      break;
    default:
      throw new JuDbException("Unsupported DB: " + this.connUtil.getDbType());
    }
   
    this.setConfigProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, dataTypeFactory);
    this.setConfigProperty(DatabaseConfig.PROPERTY_METADATA_HANDLER, metadataHandler);
  }
View Full Code Here

    Connection unwrappedConn = null;
    if (this.connUtil.getDbType() == DbType.ORACLE && connection instanceof Proxy) {
      try {
        unwrappedConn = connection.unwrap(Connection.class);
      } catch (Exception ex) {
        throw new JuDbException("Couldn't unwrap Connection", ex);
      }
    }
    final Connection realConn = unwrappedConn != null
        ? unwrappedConn
        : connection;
   
    try {
      // Check if we get the same connection. If so, we'll recycle the DatabaseConnection to avoid
      // requerying of all the DB meta data
      if (this.dbConn == null || this.dbConn.getConnection() != connection) {
        this.dbConn = new DatabaseConnection(realConn, this.schemaName);
       
        for (String key : this.configProperties.keySet()) {
          this.dbConn.getConfig().setProperty(key, this.configProperties.get(key));
        }
        logger.debug("Created DatabaseConnection: {}", this.dbConn);
      } else {
        // Use existing DatabaseConnection
        logger.info("Reusing DatabaseConnection {}", this.dbConn.getConnection());
      }
      work.execute(this.dbConn);
    } catch (Exception ex) {
      throw new JuDbException("Couldn't execute DbUnitWork", ex);
    }
  }
View Full Code Here

    public ExportBuilder setTableNamesCasingByDataSet(String resourcePath) {
      try {
        this.exportItems.setCasedTableNames(new XPathGetter(XmlUtils.loadXml(
            JuUrl.resource().relativeTo(DbDataUtil.class).get(resourcePath))).getNodeNames("dataset/*"));
      } catch (Exception ex) {
        throw new JuDbException("Couldn't load table names data set " + resourcePath, ex);
      }
      return this;
    }
View Full Code Here

          }
        }
       
        return this;
      } catch (Exception ex) {
        throw new JuDbException("Couldn't add tables by dataset " + resourceUrl, ex);
      }
    }
View Full Code Here

          try {
            XmlOutputConverter xmlConv = new XmlOutputConverter();
            ExportBuilder.writeToXml(dataSet, xmlConv.getOutputStream());
            doc.setValue(xmlConv);
          } catch (Exception ex) {
            throw new JuDbException("Couldn't write DB data to XML Output Converter", ex);
          }
        }
      });
     
      return doc.getValue();
View Full Code Here

          .setCaseSensitiveTableNames(false)
          .build(xmlUrl);
        this.dataSetUrl = xmlUrl;
        return this;
      } catch (Exception ex) {
        throw new JuDbException("Couldn't import data from XML: " + xmlUrl, ex);
      }
    }
View Full Code Here

        public void execute(IDatabaseConnection conn) {
          try {
            logger.debug("Executing Clean-Insert from: " + dataSetUrl);
            DatabaseOperation.CLEAN_INSERT.execute(conn, getDataSet(conn));
          } catch (Exception ex) {
            throw new JuDbException("Couldn't clean and insert data into DB", ex);
          }
        }
      });
    }
View Full Code Here

        public void execute(IDatabaseConnection conn) {
          try {
            logger.debug("Executing Delete-All from: " + dataSetUrl);
            DatabaseOperation.DELETE_ALL.execute(conn, getDataSet(conn));
          } catch (Exception ex) {
            throw new JuDbException("Couldnt truncate data in DB", ex);
          }
        };
      });
    }
View Full Code Here

TOP

Related Classes of ch.inftec.ju.db.JuDbException

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.