Package org.xmlBlaster.contrib.dbwriter.info

Examples of org.xmlBlaster.contrib.dbwriter.info.SqlInfo


         if (doCheck) {
            checked = true;
            // first check parsing (if an assert occurs here it means there is a discrepancy between toXml and parse
            SqlInfoParser parser = new SqlInfoParser();
            parser.init(info);
            SqlInfo dbUpdateInfo = parser.parse(msg);
            String createStatement = dbSpecific.getCreateTableStatement(dbUpdateInfo.getDescription(), null);
            log.fine("=============================================");
            log.fine(createStatement);
            log.fine("=============================================");
            String msg1 = dbUpdateInfo.toXml("");
            log.fine("original message: " + message);
            log.fine("parsed message: " + msg1);
            int numOfCols = dbUpdateInfo.getDescription().getColumns().length;
            assertTrue("Number of columns must be at least one (to detect that metadata is retrieved)", numOfCols > 0);
            assertXMLEqual("Parsing of message is working correctly: output xml is not the same as input xml", msg, msg1);

            TableToWatchInfo tableToWatch = new TableToWatchInfo();
            tableToWatch.setActions("IDU");
            String functionAndTrigger = dbSpecific.createTableTrigger(dbUpdateInfo.getDescription(), tableToWatch);
           
            log.fine("-- ---------------------------------------------------------------------------");
            log.fine(functionAndTrigger);
            log.fine("-- ---------------------------------------------------------------------------");
           
            // check now the creation of the table
            String sql = "DROP TABLE TEST_CREATION";
            try {
               dbPool.update(sql);
            }
            catch (Exception e) {
            }

            dbUpdateInfo.getDescription().setIdentity("TEST_CREATION");
            sql = dbSpecific.getCreateTableStatement(dbUpdateInfo.getDescription(), null);
            try {
               dbPool.update(sql);
            }
            catch (Exception ex) {
               ex.printStackTrace();
View Full Code Here


        
         // first check parsing (if an assert occurs here it means there is a discrepancy between toXml and parse
         SqlInfoParser parser = new SqlInfoParser();
         parser.init(info);

         SqlInfo dbUpdateInfo = parser.parse(message);
         String sql = this.dbSpecific.getCreateTableStatement(dbUpdateInfo.getDescription(), null);
         try {
            this.replicationWriter.store(dbUpdateInfo);
         }
         catch (Exception e) {
            e.printStackTrace();
View Full Code Here

               rs.close();
            if (st != null)
               st.close();
            return;
         }
         SqlInfo obj = new SqlInfo(this.info);
         obj.fillMetadata(conn, null, schemaName, tableName, rs, null);

         int maxCount = 20;
         int count = 0;
         while (rs.next() && count < maxCount) {
            obj.fillOneRowWithObjects(rs, null);
            count++;
         }

         rs.close();
         st.close();
         // obj.getDescription().addPreparedStatements();

         count = obj.getRowCount();
         if (count == 0) {
            log.info("Could not test '" + name + "' since empty");
         }
         else {
            List rows = obj.getRows();
            SqlDescription desc = obj.getDescription();

            conn.setAutoCommit(false);
            try {
               for (int i=0; i < rows.size(); i++) {
                  SqlRow row = (SqlRow)rows.get(i);
View Full Code Here

      List nonExisting = new ArrayList();
      List toProcess = new ArrayList();
      Map tableMap = new HashMap();
       for (int i=0; i < tables.length; i++) {
          try {
             SqlInfo sqlInfo = new SqlInfo(info);
             String catalog = tables[i].getCatalog();
             String schema =  tables[i].getSchema();
             String tableName = tables[i].getTable();
             tableMap.put(tableName, tables[i]);
             sqlInfo.fillMetadata(conn, catalog, schema, tableName, null, null);
             toProcess.add(sqlInfo.getDescription());
          }
          catch (Throwable ex) {
             ex.printStackTrace();
             nonExisting.add(tables[i]);
          }
View Full Code Here

     
      try {
         I_Info info = new PropertiesInfo(System.getProperties());
         SqlInfoParser parser = new SqlInfoParser();
         parser.init(info);
         SqlInfo sqlInfo = parser.readObject(new FileInputStream(args[0]), null);
         System.out.println("Number of rows: " + sqlInfo.getRowCount());
      }
      catch (Exception ex) {
         ex.printStackTrace();
      }
   }
View Full Code Here

         inputSource = new InputSource(is);
      if (encoding != null)
         inputSource.setEncoding(encoding); // this only has an effect if the input source contains an InputStream an not
                                   // a character stream (Reader)
      try {
         this.updateRecord = new SqlInfo(this.info);
         init(inputSource);      // use SAX parser to parse it (is slow)
         return this.updateRecord;
      }
      catch (XmlBlasterException ex) {
         log.fine("SqlInfoParser.readObject: could not parse input stream");
View Full Code Here

                      processComment(pos, line, "-->");
                }
             }
             if(content != null) {
                if(sqlInfoParser != null) {
                   SqlInfo obj = sqlInfoParser.parse(content);
                   content = obj.toXml("");
                }
                System.out.println("Date (old):  " + new Date(nextTime));
                System.out.println("Date (new):  " + new Date(calculateNewTime(nextTime)));
                System.out.println("Date (old):  " + new Time(nextTime));
                System.out.println("Date (new):  " + new Time(calculateNewTime(nextTime)));
View Full Code Here

             }
          }
         
          if(content != null) {
             if(sqlInfoParser != null) {
                SqlInfo obj = sqlInfoParser.parse(content);
                content = obj.toXml("");
             }
             long fireTime = calculateNewTime(nextTime);
             long delay = fireTime - System.currentTimeMillis();
             if(delay < 0L || immediate)
                delay = minDelay;
View Full Code Here

   /**
    * @see org.xmlBlaster.contrib.replication.I_DbSpecific#addTrigger(java.sql.Connection, java.lang.String, java.lang.String, java.lang.String, org.xmlBlaster.contrib.dbwriter.info.SqlInfo)
    */
   public void addTrigger(Connection conn, String catalog, String schema, String tableName) throws Exception {
      TableToWatchInfo tableToWatch = getTableToWatch(conn, catalog, schema, tableName);
      SqlInfo sqlInfo = new SqlInfo(this.info);
      if (sqlInfo.fillMetadata(conn, catalog, schema, tableName, null, null)) {
         final boolean force = true;
         addTrigger(conn, tableToWatch, sqlInfo, force);
      }
      else
         log.warning("The table='" + tableName + "' on schema='" + schema + "' and catalog='" + catalog + "' has not been found");
View Full Code Here

      try {
         conn.setAutoCommit(true);
         oldTransIsolation = conn.getTransactionIsolation();
         oldTransIsolationKnown = true;
         SqlInfo sqlInfo = new SqlInfo(this.info);

         if (catalog != null)
            catalog = this.dbMetaHelper.getIdentifier(catalog);
         if (schema != null)
            schema = this.dbMetaHelper.getIdentifier(schema);
         table = this.dbMetaHelper.getIdentifier(table);

         sqlInfo.fillMetadata(conn, catalog, schema, table, null, null);
         SqlDescription description = sqlInfo.getDescription();
         description.addAttributes(attrs);

         // check if function and trigger are necessary (they are only if the
         // table has to be replicated.
         // it does not need this if the table only needs an initial synchronization.
View Full Code Here

TOP

Related Classes of org.xmlBlaster.contrib.dbwriter.info.SqlInfo

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.