Examples of IDatabaseConnection


Examples of org.dbunit.database.IDatabaseConnection

        }

        Connection jdbcConnection=null;
        Statement statement=null;
        try {
            IDatabaseConnection connection = new DatabaseDataSourceConnection(new InitialContext(),
                "java:jboss/datasources/RHQDS");
            jdbcConnection = connection.getConnection();
            statement = jdbcConnection.createStatement();
            statement.execute("DROP TABLE RHQ_SUBJECT CASCADE");
        } catch (Exception e) {
            System.err.println("== drop subject table failed: " + e.getMessage());
        } finally {
View Full Code Here

Examples of org.dbunit.database.IDatabaseConnection

        Connection connection = null;

        try {
            connection = getConnection();
            IDatabaseConnection dbUnitConnection = new DatabaseConnection(connection);
            DatabaseOperation.REFRESH.execute(dbUnitConnection, getDataSet());
        } finally {
            if (connection != null) {
                connection.close();
            }
View Full Code Here

Examples of org.dbunit.database.IDatabaseConnection

        if ("true".equals(System.getProperty("clean.db"))) {
            Connection connection = null;

            try {
                connection = getConnection();
                IDatabaseConnection dbUnitConnection = new DatabaseConnection(connection);
                DatabaseOperation.DELETE.execute(dbUnitConnection, getDataSet());
            } finally {
                if (connection != null) {
                    connection.close();
                }
View Full Code Here

Examples of org.dbunit.database.IDatabaseConnection

        EntityManager em = null;
        try {
            em = entityManagerFactory.createEntityManager();
            Connection conn = getConnection(em);
            assert null != conn;
            IDatabaseConnection dbunitConn = new DatabaseConnection(conn);
            // only if we are running against HSQL
            String dbProdName = conn.getMetaData().getDatabaseProductName();
            if (dbProdName.toLowerCase().contains("hsql")) {
                DatabaseConfig config = dbunitConn.getConfig();
                config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
                        new HsqlDataTypeFactory());
            }
            IDataSet dataSet = loadDataSet(dbunitConn);
            databaseTester = new DefaultDatabaseTester(dbunitConn);
View Full Code Here

Examples of org.dbunit.database.IDatabaseConnection

  protected void initPersistenceStuff() throws Exception {
    EntityManager em = null;
    try {
      em = entityManagerFactory.createEntityManager();
      Connection conn = getConnection(em);
      IDatabaseConnection dbunitConn = new DatabaseConnection(conn);
      IDataSet dataSet = loadDataSet(dbunitConn);
      databaseTester = new DefaultDatabaseTester(dbunitConn);
      databaseTester.setDataSet(dataSet);
      databaseTester.setSetUpOperation(DatabaseOperation.CLEAN_INSERT);
      databaseTester.onSetup();
View Full Code Here

Examples of org.dbunit.database.IDatabaseConnection

                    dbService.start();

                    PersistenceAdapter adapter = dbService.getAdapter();
                    connection = adapter.getConnection();
                }
                IDatabaseConnection dbConnection
                        = new DatabaseConnection(connection);
                IDataSet fullDataSet = dbConnection.createDataSet();
                FlatXmlDataSet.write(fullDataSet,
                                     new FileOutputStream(outputPath));
            } catch (Exception exception) {
                exception.printStackTrace();
                System.exit(1);
View Full Code Here

Examples of org.dbunit.database.IDatabaseConnection

        // import the data from the proxy database into 'migrated'
        Importer importer = new Importer(migrated, DB_NAME, true);
        importer.apply();

        // verify data between the two master databases
        IDatabaseConnection masterConn = getConnection(master);
        IDatabaseConnection migratedConn = getConnection(migrated);
        IDataSet expectedDataSet = masterConn.createDataSet();
        IDataSet actualDataSet = migratedConn.createDataSet();

        // NOTE: don't care about the contents of the 'seeds' and 'system_data'
        // tables as neither are explicitly migrated, and the contents of
        // each may differ
        checkQuery("destinations", DESTINATIONS_QUERY, masterConn,
View Full Code Here

Examples of org.dbunit.database.IDatabaseConnection

    * @param outputFolder
    * @throws Exception
    */
  public void fullExport(String outputFolder) throws Exception{   

     IDatabaseConnection conn = null;
   
     try {
       if(outputFolder == null || outputFolder.equalsIgnoreCase(""))
           throw new Exception("Invalid destination folder !");
     
       BasicDataSource ds = DatabaseConnectionFactory.getDataSource();
       conn = new DatabaseConnection(ds.getConnection());
      
       //conn = DatabaseConnectionFactory.getConnection();       
       String targetDbName = DatabaseConnectionFactory.getDatabaseName()
      
       ITableFilter tablefilter = new DatabaseSequenceFilter(conn);       
       IDataSet databaseDataSet = new FilteredDataSet(tablefilter, conn.createDataSet());  
      
       //the name of the created file is equal at the DB name
       FlatXmlDataSet.write(databaseDataSet, new FileOutputStream(outputFolder+File.separator+targetDbName+".xml"));          
     
    } catch (Exception e) {
      throw e;
     
    } finally{
      if(conn !=null)
         conn.close();
    }
   }
View Full Code Here

Examples of org.dbunit.database.IDatabaseConnection

    * @param query The query to extract the data-set to export
    * @throws Exception
    */
  public void partialExport(String outputFolder, List<TableInfoPartialExportBean> filteredTableToExport) throws Exception{
   
    IDatabaseConnection conn = null;
   
    try {
      if(outputFolder == null || outputFolder.equalsIgnoreCase(""))
        throw new Exception("Invalid destination folder !");
           
      BasicDataSource ds = DatabaseConnectionFactory.getDataSource();
      conn = new DatabaseConnection(ds.getConnection());
      
      if(filteredTableToExport.size() >0)
      {     
        String targetDbName = DatabaseConnectionFactory.getDatabaseName();       
        QueryDataSet partialDataSet = new QueryDataSet(conn)
       
        // build the data-set. NOTE: the new inserted value will be inserted in the model only when the editable cell lose the focuc
        for(int i=0;i<filteredTableToExport.size();i++){         
             //System.out.println(filteredTableToExport.get(i).isIncludeTable());
             //System.out.println("ADD: "+filteredTableToExport.get(i).getTableName()+","+filteredTableToExport.get(i).getExportQuery());
             partialDataSet.addTable(filteredTableToExport.get(i).getTableName(),filteredTableToExport.get(i).getExportQuery());
          }   
               
        FlatXmlDataSet.write(partialDataSet, new FileOutputStream(outputFolder+File.separator+targetDbName+".xml"));  
       
      }else
        throw new Exception("Select at least one table !");
    } catch (Exception e) {
      throw e;
     
    }finally{
      if(conn !=null)
         conn.close();
      }   
   }
View Full Code Here

Examples of org.dbunit.database.IDatabaseConnection

    * @param tableName
    * @throws Exception
    */
  public void dependencyExport(String outputFileName, String tableName) throws Exception{
   
    IDatabaseConnection conn = null;
   
     try{   
       BasicDataSource ds = DatabaseConnectionFactory.getDataSource();
       conn = new DatabaseConnection(ds.getConnection());
      
       String[] depTableNames = TablesDependencyHelper.getAllDependentTables(conn, tableName );
       IDataSet depDataSet = conn.createDataSet( depTableNames );
       FlatXmlDataSet.write(depDataSet, new FileOutputStream(outputFileName));
     
    } catch (Exception e) {
      throw e;
     
    }finally{
       if(conn !=null)
        conn.close();
    }
   }
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.