Package org.xmlBlaster.contrib.db

Examples of org.xmlBlaster.contrib.db.I_DbPool


    */
   public final void testCheckSequenceForCreation() throws Exception {
      currentMethod = new String("testCheckSequenceForCreation");
      log.info("Start " + currentMethod);
      SpecificDefault specificDefault = (SpecificDefault)dbSpecific;
      I_DbPool pool = (I_DbPool)info.getObject("db.pool");
      assertNotNull("pool must be instantiated", pool);
      {
         String sql = "CREATE SEQUENCE repl_seq  values(sss)";
         int ret = specificDefault.checkSequenceForCreation(sql);
         assertEquals("check the operation of SpecificDefault.checkSequenceForCreation('" + sql + "')", 0, ret);
View Full Code Here


               if (readerInfo.getBoolean("replication.doBootstrap", false)) {
                  boolean needsPublisher = readerInfo.getBoolean(I_DbSpecific.NEEDS_PUBLISHER_KEY, true);
                  boolean forceCreationAndInitNo = false;
                  dbSpecific = ReplicationConverter.getDbSpecific(readerInfo, forceCreationAndInitNo); // done only on master !!!
                  readerInfo.put(I_DbSpecific.NEEDS_PUBLISHER_KEY, "" + needsPublisher); // back to original
                  I_DbPool pool = (I_DbPool)readerInfo.getObject("db.pool");
                  if (pool == null)
                     throw new Exception("ReplicationAgent.init: the db pool is null");
                  Connection conn = pool.reserve();
                  try {
                     boolean doWarn = false;
                     boolean force = false;
                     dbSpecific.bootstrap(conn, doWarn, force);
                  }
View Full Code Here

      if (info == null)
         info = writerInfo;
      if (info == null)
         return;
     
      I_DbPool pool = (I_DbPool)info.getObject("db.pool");
      Connection conn = null;
     
      String prompt = "master>";
      if (readerInfo == null)
         prompt = "slave>";
     
      System.out.println(prompt + "make your sql statement");
      System.out.print(prompt);
      String line = null;
      while ( (line = br.readLine()) != null) {

         if (line.trim().length() < 1) {
            System.out.print(prompt);
            continue;
         }
         line = line.trim();
         if (line.equalsIgnoreCase("q") ||
               line.equalsIgnoreCase("quit") ||
               line.equalsIgnoreCase("exit") ||
               line.equalsIgnoreCase("stop") ||
               line.equalsIgnoreCase("finish"))
            break;

         try {
            conn  = pool.reserve();
            Statement st = conn.createStatement();
            boolean ret = st.execute(line);
            if (ret) {
               ResultSet rs = st.getResultSet();
               while (rs.next()) {
View Full Code Here

   }

  
   public static I_DbPool getDbPool(I_Info info) throws Exception {
      synchronized (info) {
         I_DbPool dbPool = (I_DbPool)info.getObject("db.pool");
         if (dbPool == null) {
            ClassLoader cl = DbWatcher.class.getClassLoader();
            String dbPoolClass = info.get("dbPool.class", "org.xmlBlaster.contrib.db.DbPool");
            if (dbPoolClass.length() > 0) {
                dbPool = (I_DbPool)cl.loadClass(dbPoolClass).newInstance();
                if (log.isLoggable(Level.FINE))
                   log.fine(dbPoolClass + " created and initialized");
            }
            else
               throw new IllegalArgumentException("Couldn't initialize I_DbPool, please configure 'dbPool.class' to provide a valid JDBC access.");
            info.putObject("db.pool", dbPool);
         }
         dbPool.init(info);
         return dbPool;
      }
   }
View Full Code Here

    *
    * @param args
    *           Command line
    */
   public static void main(String[] args) {
      I_DbPool pool = null;
      Connection conn = null;
      try {
        
         System.setProperty("java.util.logging.config.file",
               "testlog.properties");
         // LogManager.getLogManager().readConfiguration();

         // Preferences prefs = Preferences.userRoot();
         // prefs.node(ReplicationConstants.CONTRIB_PERSISTENT_MAP).clear();
         // prefs.clear();

         // ---- Database settings -----
         if (System.getProperty("jdbc.drivers", null) == null) {
            System.setProperty(
                        "jdbc.drivers",
                        "org.hsqldb.jdbcDriver:oracle.jdbc.driver.OracleDriver:com.microsoft.jdbc.sqlserver.SQLServerDriver:org.postgresql.Driver");
         }
         if (System.getProperty("db.url", null) == null) {
            System.setProperty("db.url", "jdbc:postgresql:test//localhost/test");
         }
         if (System.getProperty("db.user", null) == null) {
            System.setProperty("db.user", "postgres");
         }
         if (System.getProperty("db.password", null) == null) {
            System.setProperty("db.password", "");
         }

         I_Info info = new PropertiesInfo(System.getProperties());
         boolean forceCreationAndInit = true;
         I_DbSpecific specific = ReplicationConverter.getDbSpecific(info, forceCreationAndInit);
         pool = (I_DbPool) info.getObject("db.pool");
         conn = pool.reserve();
         conn.setAutoCommit(true);
         String schema = info.get("wipeout.schema", null);
         String version = info.get("replication.version", "0.0");
         if (schema == null) {
            String initialUpdateFile = info.get("initialUpdate.file", null);
View Full Code Here

            System.setProperty("db.password", "xbl");
         }
         SpecificOracle oracle = new SpecificOracle();
         I_Info info = new PropertiesInfo(System.getProperties());
         oracle.init(info);
         I_DbPool pool = (I_DbPool) info.getObject("db.pool");
         Connection conn = pool.reserve();
         String objectTypes = info.get("objectTypes", null);
         String schema = info.get("schema", "AIS");
         String referencedSchema = info.get("referencedSchema", null);
         oracle.cleanupSchema(schema, objectTypes, referencedSchema);
         conn = SpecificDefault.releaseIntoPool(conn, COMMIT_NO, pool);
View Full Code Here

      return set;
   }

   public void init(I_Info info) throws Exception {
      log.info("init");
      I_DbPool pool = (I_DbPool)info.getObject(DbWriter.DB_POOL_KEY);
      DbMetaHelper dbHelper = null;
      if (pool == null) {
         log.warning("DefaultMapper.init: the pool has not been configured, please check your '" + DbWriter.DB_POOL_KEY + "' configuration settings");
      }
      else
View Full Code Here

      return this.poolOwner;
   }

  
   private final static I_DbPool createPool(ClassLoader cl, I_Info info) throws Exception {
      I_DbPool dbPool = (I_DbPool)info.getObject("db.pool");
      if (dbPool == null) {
         String dbPoolClass = info.get("dbPool.class", "org.xmlBlaster.contrib.db.DbPool");
         if (dbPoolClass.length() > 0) {
             dbPool = (I_DbPool)cl.loadClass(dbPoolClass).newInstance();
             dbPool.init(info);
             if (log.isLoggable(Level.FINE)) log.fine(dbPoolClass + " created and initialized");
         }
         else
            throw new IllegalArgumentException("Couldn't initialize I_DbPool, please configure 'dbPool.class' to provide a valid JDBC access.");
         setPoolOwner(null, true);
View Full Code Here

      addIfNotSet("db.url", dbUrl);
      addIfNotSet("db.user", dbUser);
      addIfNotSet("db.password", dbPassword);
      addIfNotSet("db.drivers", dbDrivers);
     
      I_DbPool newPool = new DbPool();
     
      newPool.init(this);
      this.persistentInfo = new DbInfo(newPool, "replication", this);
      return newPool;
   }
View Full Code Here

      sb.append(offset).append("</").append(SQL_TAG).append(">");
      return sb.toString();
   }
  
   public static SqlInfo getStructure(I_Info info) throws Exception {
      I_DbPool pool = (I_DbPool) info.getObject("db.pool");
      Connection conn = null;
      try {
         SqlInfo sqlInfo = new SqlInfo(info);
         SqlDescription description = new SqlDescription(info);
         conn = pool.reserve();
         conn.setAutoCommit(true);
         ArrayList list = new ArrayList();
         TableToWatchInfo.getSortedTablesToWatch(conn, info, list);
         for (int i=0; i < list.size(); i++) {
            SqlDescription descr = (SqlDescription)list.get(i);
            SqlColumn[] cols = descr.getColumns();
            for (int j=0; j < cols.length; j++) {
               description.addColumn(cols[j]);
            }
         }
         sqlInfo.setDescription(description);
         return sqlInfo;
      }
      finally {
         if (conn != null)
            pool.release(conn);
      }
   }
View Full Code Here

TOP

Related Classes of org.xmlBlaster.contrib.db.I_DbPool

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.