Package ch.epfl.lbd.database.providers.oracle.connection

Examples of ch.epfl.lbd.database.providers.oracle.connection.OracleConnection


   
    //SOURCE TABLE
    RelationalTable source = new RelationalTable(tableName,columns);
   
    //SOURCE DATABASE
    OracleConnection sourceConnection = new OracleConnection("connections.properties","connection1");
    sourceConnection.openConnection();
   
    //DESTINATION TABLE
    RelationalTable destination = new RelationalTable(tableName,columns);
    destination.setForced(true);
   
    //DESTINATION DATABASE
    PostgreSqlConnection destinationConnection = new PostgreSqlConnection("connections.properties","connection4");
    destinationConnection.openConnection();
   
    //LOAD TABLES
    source.loadObject(sourceConnection);
    destination.setTypes(source.getTypes());
    destination.loadObject(destinationConnection);
   
    double size = source.size();
    logger.info("source table size is "+size);
   
    logger.info("populating destination table");
    DecimalFormat twoPlaces = new DecimalFormat("0.00");

    double i = 0;
    while(true){
      i++;
      boolean success = destination.insertRow(source.getNextRow());
      if(!success) break;
      logger.info(twoPlaces.format((i/size)*100)+"% done...");
    }
   
    logger.info("destination table size is "+destination.size());
   
    //RELEASE OBJECT LOCKS AND MEMORY
    source.releaseObject();
    destination.releaseObject();
   
    //CLOSE DATABASE CONNECTIONS
    sourceConnection.closeConnection();
    destinationConnection.closeConnection();
  }
View Full Code Here


   
    //SOURCE TABLE
    RelationalTable source = new RelationalTable(tableName,columns);
   
    //SOURCE DATABASE
    OracleConnection sourceConnection = new OracleConnection("connections.properties","connection1");
    sourceConnection.openConnection();
   
    //DESTINATION TABLE
    RelationalTable destination = new RelationalTable(tableName,columns);
    destination.setForced(true);
   
    //DESTINATION DATABASE
    PostgreSqlConnection destinationConnection = new PostgreSqlConnection("connections.properties","connection4");
    destinationConnection.openConnection();
   
    //LOAD TABLES
    source.loadObject(sourceConnection);
    destination.setTypes(source.getTypes());
    destination.loadObject(destinationConnection);
   
    double size = source.size();
    logger.info("source table size is "+size);
   
    logger.info("populating destination table");
    double i = 0;
    while(true){
      i++;
      boolean success = destination.insertRow(source.getNextRow());
      if(!success) break;
      logger.info((i/size)+"% done...");
    }
   
    logger.info("destination table size is "+destination.size());
   
    //RELEASE OBJECT LOCKS AND MEMORY
    source.releaseObject();
    destination.releaseObject();
   
    //CLOSE DATABASE CONNECTIONS
    sourceConnection.closeConnection();
    destinationConnection.closeConnection()
  }
View Full Code Here

    String tableName = "MILAN_GMD3";
    int ROWS_TO_FETCH = 1;
    //RelationalTable table = new RelationalTable(tableName,columns);
    RelationalTable table = new RelationalTable(tableName);

    OracleConnection connection = new OracleConnection("src/connections.properties","connection1");
    connection.openConnection();
    table.loadObject(connection);
   
    logger.info("table size is "+table.size());
   
    for(int count = 0 ; count < ROWS_TO_FETCH ; count ++ ){
      Object[] data = table.getNextRow();
      logger.info(" ---- ROW "+count+" ---- ");
      for(int i = 0 ; i<columns.length ; i++ ){
        logger.info("data: "+columns[i]+" - "+data[i].toString());
      }
    }
   
    table.releaseObject();
   
    String[] columns2 = {"NAME","TIMEDATE","VALUE"};
    String tableName2 = "TEST";
   
    RelationalTable table2 = new RelationalTable(tableName2,columns2);
    table2.setForced(true);
    table2.loadObject(connection);
    Object[] values = new Object[3];
    values[0] = "name1";
    DateFormat formatter = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
        Date date = (Date)formatter.parse("2002.01.29.08.36.33");

    values[1] = date;
    values[2] = 1.992;
   
    table2.insertRow(values);
    table2.releaseObject();
    connection.closeConnection();
  }
View Full Code Here

   
    super.run();
    switch(type){
    case FROM_LATLNG_COLUMNS:
      if(connection.getClass() == OracleConnection.class){
        OracleConnection oracle = (OracleConnection)connection;
        try{
          String addColumnQuery = "alter table "+
             tblName+
             " add "+
             "( "+
                streetColumnName+" varchar(64)"+
              " )";
         
          oracle.executeSQLQuery(addColumnQuery);
          logger.info("Column inserted");
        }
        catch(Exception e){
          logger.error("the column is already created");
        }
       
        String getTotal = "SELECT count(*) as total "+
           "FROM "+tblName+" "+
           "WHERE "+streetColumnName+" IS NULL";
 
        ResultSet rset = oracle.getSQLQueryResults(getTotal);
        int total = 0;
        if(rset.next())total = rset.getInt("total");
       
        String query = "SELECT "+id+", "+latColumn+", "+lngColumn+" "+
                 "FROM "+tblName+" "+
                 "WHERE "+streetColumnName+" IS NULL";
       
        rset = oracle.getSQLQueryResults(query);
       
        logger.info("Dataset retrieved");
       
        int i = 0;       
        double lastStatus = 0;
        DecimalFormat twoPlaces = new DecimalFormat("0.00");

        while (rset.next()){
         
          String idValue = rset.getString(id);
          double latValue = rset.getDouble(latColumn);
          double lngValue = rset.getDouble(lngColumn);

          String address = geocoder.getGoogleAddress(latValue, lngValue);
         
          logger.info(address);
         
          String insertQuery = "UPDATE "+tblName+
                         " SET "+streetColumnName+" = '"+address+
                     "' WHERE "+id+" = "+idValue;
         
          oracle.executeSQLQuery(insertQuery);
          i++;
         
          //logger.info(i+"-th row updated");
          step(100000000/total);
          if(getStatus() > lastStatus + 0.01){
View Full Code Here

 
  public static void main(String[] args){
   
   
    try{
      OracleConnection connection = new OracleConnection("src/connections.properties","connection1");
      connection.openConnection();
     
      AddStreetsProcedure procedure = new AddStreetsProcedure(FROM_LATLNG_COLUMNS);
      procedure.setConnection(connection);
     
      String[] parameters = new String[5];
      parameters[0] = "ID";
      parameters[1] = "MILAN_GMD3";
      parameters[2] = "STREETNAME";
      parameters[3] = "LATITUDE";
      parameters[4] = "LONGITUDE";
      procedure.setParameters(parameters);
     
      procedure.run();
     
      connection.closeConnection();
    }
    catch (Exception e) {
      // TODO: handle exception
      e.printStackTrace();
    }
View Full Code Here

  @org.junit.Test
  public void run() throws Exception{
   
    //OracleConnection connection = new OracleConnection("src/connections.properties","connection3");
   
    OracleConnection connection = new OracleConnection("zhixian-machine.xml");
   
    try{
      connection.multiDimensional = true;
      connection.openConnection();
     
      UserSession session = connection.openSession();
     
      ArrayList<String> tbls = connection.getAnalyticalWorkspaces();
      for(String table : tbls)logger.info("AWS: "+table);
     
      OracleDataWarehouse dw = new OracleDataWarehouse("owner","NEWJAVA_AW_TEST");
      dw.loadObject(connection);
     
      tbls = connection.getAnalyticalWorkspaces();
      for(String table : tbls)logger.info("AWS: "+table);
     
//      workspace.deleteAW(); 
//      tbls = connection.getAnalyticalWorkspaces();
//      for(String table : tbls)logger.info("AWS: "+table);
     
      connection.closeSession(session)
      connection.closeConnection();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

public class TestCube extends Tester {

  @org.junit.Test
  public void run() throws Exception{
   
    OracleConnection connection = new OracleConnection("src/connections.properties","connection1");
   
    try{
      connection.multiDimensional = true;
      connection.openConnection();
     
      UserSession session = connection.openSession();

      OracleDataWarehouse dw = new OracleDataWarehouse("owner","NEWJAVA_AW_TEST");
      dw.loadObject(connection);
     
      ArrayList<String>  tbls = connection.getAnalyticalWorkspaces();
      for(String table : tbls)logger.info("AWS: "+table);
     
      //OracleCube cube = new OracleCube("TEST_CUBE",workspace.getName(),connection);
     
      connection.closeSession(session)
      connection.closeConnection();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

 
  @Test
  public void run(){
   
    try{
      OracleConnection connection = new OracleConnection("zhixian-machine.xml");
     
      connection.openConnection();
      UserSession session = connection.openSession();
     
      OracleDataWarehouse dw = new OracleDataWarehouse("SIMONE","DW_2");
      dw.loadObject(connection);
     
      //create oracle dimension
      RelationalTable timeDimension = new RelationalTable("TIMEDIMENSIONTEST");
      timeDimension.loadObject(connection);
     
      OracleLevel yearLevel = new OracleLevel("YEAR 3",timeDimension,"YEAR");
      yearLevel.setDescription("the year of shipment");
      OracleLevel monthLevel = new OracleLevel("MONTH 3",timeDimension,"MONTH");
      monthLevel.setDescription("the month of shipment");
     
      OracleHierarchy hier = new OracleHierarchy("TIME HIER 3",timeDimension);
      hier.setDescription("the Time Dimension main hier");
      hier.addLevel(yearLevel);
      hier.addLevel(monthLevel);
     
      OracleDimension timeDim = new OracleDimension("TIME DIM 3",hier);
      timeDim.setDescription("Time Dimension Descr");
     
      //add it to the oracle data warehouse
      dw.addDimension(timeDim);
      timeDim.loadObject(connection);

      //release database objects
      dw.releaseObject();
     
      connection.closeSession(session)
      connection.closeConnection();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

public class TestOracleConnection extends Tester {
 
  @Test
  public void run()throws Exception{
   
    OracleConnection connection = new OracleConnection("src/connections.properties","connection1");
   
    try{
      connection.openConnection();
     
      UserSession session = connection.openSession();
     
      ArrayList<String> tbls = connection.getUserTables();
      for(String table : tbls)logger.info("Table Found: "+table);
     
      ResultSet results = connection.getSQLQueryResults("SELECT * FROM MILAN_MAP_POI",10);
      while (results.next())logger.info(results.getString(1));
      results.close();
     
      logger.info(" ---- ANALYTICAL WORKSPACES ----");
     
      tbls = connection.getAnalyticalWorkspaces();
      for(String aw : tbls)logger.info("AW: "+aw);
     
      ArrayList<String> keys = connection.getPrimaryKeys("TEST");
     
      logger.info("primary key: "+keys.get(0));
     
      int version = connection.getOracleVersion();
     
      logger.info(version);
     
      connection.closeSession(session);
     
      connection.closeConnection();
    }
    catch (Exception e) {
      // TODO: handle exception
    }
  }
View Full Code Here

  @Override
  public void run(){

    try{
      //open source connection
      sourceConnection = new OracleConnection("connections.properties","connection1");
      sourceConnection.openConnection();
      //open destination connection
      destinationConnection = new PostgreSqlConnection("connections.properties","connection4");
      destinationConnection.openConnection();
    }
View Full Code Here

TOP

Related Classes of ch.epfl.lbd.database.providers.oracle.connection.OracleConnection

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.