Examples of IDatabaseConnection


Examples of org.dbunit.database.IDatabaseConnection

    * @param inputFile
    * @throws Exception
    */
  public void importDataSet(String inputFile) throws Exception{
   
    IDatabaseConnection conn = null;
   
     try {
      if(inputFile == null || inputFile.equalsIgnoreCase(""))
        throw new Exception("Invalid input file !");
      
       BasicDataSource ds = DatabaseConnectionFactory.getDataSource();
       conn = new DatabaseConnection(ds.getConnection());
      
       //conn = DatabaseConnectionFactory.getConnection();      
       // New feature since dbunit 2.4.7
       FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();      
       IDataSet dataSet = builder.build(new File(inputFile));
  
       DatabaseOperation.INSERT.execute(conn, dataSet);
     
    } catch (Exception e) {
      throw e;
     
    } finally{
        if(conn !=null)
          conn.close();
    }    
  }
View Full Code Here

Examples of org.dbunit.database.IDatabaseConnection

       
     try
       BasicDataSource ds = DatabaseConnectionFactory.getDataSource();
         
       //ITableFilter filter = new DatabaseSequenceFilter(conn, tables);
       IDatabaseConnection conn = new DatabaseConnection(ds.getConnection());
       ITableFilter filter = new DatabaseSequenceFilter(conn, tables);
     
       //The target dataSet: ie all the tables in the input list
       IDataSet dataSet = new FilteredDataSet(filter, conn.createDataSet());     
     
       DatabaseOperation.DELETE_ALL.execute(conn, dataSet)
    
       conn.close();     
     
    }catch (Exception e) {     
      throw e;         
    }
   }
View Full Code Here

Examples of org.dbunit.database.IDatabaseConnection

   * @throws Exception
   *
   */
  public List<String> getTableNamesOrdered() throws Exception
   
    IDatabaseConnection conn = null;
   
    try{   
      //to prevent a double loading, because the table list can be loaded in many panels
      if (tableNamesList == null)
      {   
         ArrayList<String> tableListOrdered = new ArrayList<String>();        
        
         BasicDataSource ds = DatabaseConnectionFactory.getDataSource();
         conn = new DatabaseConnection(ds.getConnection());
           
         ITableFilter filter = new DatabaseSequenceFilter(conn);
         
         //The dataSet: ie the list of ALL tables name
         IDataSet dataSet = new FilteredDataSet(filter, conn.createDataSet());
       
         ITableIterator iter = dataSet.iterator();
       
         while(iter.next())
         {
           ITable tab = iter.getTable();
           String tableName = tab.getTableMetaData().getTableName();       
           tableListOrdered.add(tableName);     
         }       
       
         tableNamesList = tableListOrdered;
       
         return tableNamesList;
     
      }else     
         return tableNamesList;
   
    }catch (Exception e) {
     
      if(Log4jManager.IS_LOGGING_CONFIGURED)
        logger.fatal("Error loading tables names ordered, cause: ",e);
     
      throw new Exception("Set a valid target Database and test the connection");
     
    }finally{
       if(conn != null)
        conn.close();
    }
  }
View Full Code Here

Examples of org.dbunit.database.IDatabaseConnection

  }
 
    //TEST 
    public static List<String> getTableNamesOrderedStatic() throws Exception
   
    IDatabaseConnection conn = null;
   
    try{   
      //to prevent a double loading, because the table list can be loaded in many panels
      if (tableNamesList == null)
      {   
         ArrayList<String> tableListOrdered = new ArrayList<String>()
        
         BasicDataSource ds = DatabaseConnectionFactory.getDataSource();
         conn = new DatabaseConnection(ds.getConnection());
           
         ITableFilter filter = new DatabaseSequenceFilter(conn);
         
         //The dataSet: ie the list of ALL tables name
         IDataSet dataSet = new FilteredDataSet(filter, conn.createDataSet());
       
         ITableIterator iter = dataSet.iterator();
       
         while(iter.next())
         {
           ITable tab = iter.getTable();
           String tableName = tab.getTableMetaData().getTableName();       
           tableListOrdered.add(tableName);     
         }       
       
         tableNamesList = tableListOrdered;
       
         return tableNamesList;
     
      }else     
         return tableNamesList;
   
    }catch (Exception e) {
      throw new Exception("Set a valid target Database and test the connection");
     
    }finally{
       if(conn != null)
        conn.close();
    }
  }
View Full Code Here

Examples of org.pentaho.database.model.IDatabaseConnection

      setEnabled(isConnectionSelected());
    }

    public void actionPerformed(final ActionEvent e)
    {
      final IDatabaseConnection existingConnection = (IDatabaseConnection) dataSourceList.getSelectedValue();

      try
      {
        final Window parentWindow = LibSwingUtil.getWindowAncestor(ConnectionEditorPanel.this);
        final XulDatabaseDialog connectionDialog = new XulDatabaseDialog(parentWindow);
        final IDatabaseConnection connectionDefinition = connectionDialog.open(existingConnection);

        // See if the edit completed...
        if (connectionDefinition != null)
        {
          dialogModel.updateDatasourceById(existingConnection.getId(), connectionDefinition);
View Full Code Here

Examples of org.pentaho.database.model.IDatabaseConnection

      setEnabled(isConnectionSelected());
    }

    public void actionPerformed(final ActionEvent e)
    {
      final IDatabaseConnection source = (IDatabaseConnection) dataSourceList.getSelectedValue();
      if (source != null)
      {
        dialogModel.deleteDatasourceById(source.getId());
        dataSourceModel.removeElement(source);
      }
    }
View Full Code Here

Examples of org.pentaho.database.model.IDatabaseConnection

    {
      try
      {
        final Window parentWindow = LibSwingUtil.getWindowAncestor(ConnectionEditorPanel.this);
        final XulDatabaseDialog connectionDialog = new XulDatabaseDialog(parentWindow);
        final IDatabaseConnection connectionDefinition = connectionDialog.open(null);

        if (connectionDefinition != null &&
            !StringUtils.isEmpty(connectionDefinition.getName()))
        {
          // A new JNDI source was created
          dialogModel.createDatasource(connectionDefinition);
          dataSourceModel.addElement(connectionDefinition);
          dataSourceList.setSelectedValue(connectionDefinition, true);
View Full Code Here

Examples of org.pentaho.database.model.IDatabaseConnection

    {
      final DataSourceMgmtService datasourceMgmtSvc =
          ClassicEngineBoot.getInstance().getObjectFactory().get(DataSourceMgmtService.class);
      try
      {
        final IDatabaseConnection databaseConnection = datasourceMgmtSvc.getDatasourceByName(datasource);
        return PooledDatasourceHelper.setupPooledDataSource(databaseConnection);
      }
      catch(DatasourceMgmtServiceException daoe)
      {
        return queryFallback(datasource);
View Full Code Here

Examples of org.pentaho.database.model.IDatabaseConnection

    final SerializedConnection connection = connectionsById.get(id);
    if (connection == null)
    {
      throw new NonExistingDatasourceException();
    }
    final IDatabaseConnection databaseConnection = connection.getConnection();
    connectionsByName.remove(databaseConnection.getName());
    connectionsById.remove(databaseConnection.getId());

    writeChanges();
  }
View Full Code Here

Examples of org.pentaho.database.model.IDatabaseConnection

    editedMembers.remove(id);
  }

  public IDatabaseConnection getDatasourceByName(final String name) throws DatasourceMgmtServiceException
  {
    final IDatabaseConnection dataSource = parent.getDatasourceByName(name);
    if (deletedMembersById.contains(dataSource.getId()))
    {
      throw new NonExistingDatasourceException();
    }
    return dataSource;
  }
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.