Examples of StandardXAPoolDataSource


Examples of org.enhydra.jdbc.pool.StandardXAPoolDataSource

      ds.setUrl(props.get("connection.url"));
      ds.setUser(props.get("connection.login"));
      ds.setPassword(props.get("connection.password"));
      ds.setTransactionManager(txService_.getTransactionManager());

      StandardXAPoolDataSource pool = new StandardXAPoolDataSource(3);
      pool.setMinSize(Integer.parseInt(props.get("connection.min-size")));
      pool.setMaxSize(Integer.parseInt(props.get("connection.max-size")));
      pool.setUser(props.get("connection.login"));
      pool.setPassword(props.get("connection.password"));
      pool.setDataSource(ds);
      return pool;
   }
View Full Code Here

Examples of org.enhydra.jdbc.pool.StandardXAPoolDataSource

    public static final String module = XaPoolConnectionFactory.class.getName();

    protected static Map dsCache = new HashMap();

    public static Connection getConnection(String helperName, Element jotmJdbcElement) throws SQLException, GenericEntityException {
        StandardXAPoolDataSource pds = (StandardXAPoolDataSource) dsCache.get(helperName);
        if (pds != null) {
            if (Debug.verboseOn()) Debug.logVerbose(helperName + " pool size: " + pds.pool.getCount(), module);
            return TransactionFactory.getCursorConnection(helperName, pds.getConnection());
        }

        synchronized (XaPoolConnectionFactory.class) {
            pds = (StandardXAPoolDataSource) dsCache.get(helperName);
            if (pds != null) {
                return pds.getConnection();
            }

            // the xapool wrapper class
            String wrapperClass = jotmJdbcElement.getAttribute("pool-xa-wrapper-class");

            StandardXADataSource ds = null;
            try {
                //ds =  new StandardXADataSource();
                ds = (StandardXADataSource) ObjectType.getInstance(wrapperClass);
                pds = new StandardXAPoolDataSource();
            } catch (NoClassDefFoundError e) {
                throw new GenericEntityException("Cannot find xapool.jar");
            } catch (ClassNotFoundException e) {
                throw new GenericEntityException("Cannot load wrapper class: " + wrapperClass, e);
            } catch (InstantiationException e) {
                throw new GenericEntityException("Unable to instantiate " + wrapperClass, e);
            } catch (IllegalAccessException e) {
                throw new GenericEntityException("Problems getting instance of " + wrapperClass, e);
            }

            if (ds == null)
                throw new GenericEntityException("StandardXaDataSource was not created, big problem!");

            ds.setDriverName(jotmJdbcElement.getAttribute("jdbc-driver"));
            ds.setUrl(jotmJdbcElement.getAttribute("jdbc-uri"));
            ds.setUser(jotmJdbcElement.getAttribute("jdbc-username"));
            ds.setPassword(jotmJdbcElement.getAttribute("jdbc-password"));
            ds.setDescription(helperName);
            ds.setTransactionManager(TransactionFactory.getTransactionManager());

            String transIso = jotmJdbcElement.getAttribute("isolation-level");
            if (transIso != null && transIso.length() > 0) {
                if ("Serializable".equals(transIso)) {
                    ((StandardXADataSource) ds).setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
                } else if ("RepeatableRead".equals(transIso)) {
                    ((StandardXADataSource) ds).setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
                } else if ("ReadUncommitted".equals(transIso)) {
                    ((StandardXADataSource) ds).setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
                } else if ("ReadCommitted".equals(transIso)) {
                    ((StandardXADataSource) ds).setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
                } else if ("None".equals(transIso)) {
                    ((StandardXADataSource) ds).setTransactionIsolation(Connection.TRANSACTION_NONE);
                }
            }

            // set the datasource in the pool
            pds.setDataSource(ds);
            pds.setDescription(ds.getDescription());
            pds.setUser(ds.getUser());
            pds.setPassword(ds.getPassword());
            Debug.logInfo("XADataSource: " + ds.getClass().getName() + " attached to pool.", module);

            // set the transaction manager in the pool
            pds.setTransactionManager(TransactionFactory.getTransactionManager());

            // configure the pool settings
            try {
                pds.setMaxSize(Integer.parseInt(jotmJdbcElement.getAttribute("pool-maxsize")));
                pds.setMinSize(Integer.parseInt(jotmJdbcElement.getAttribute("pool-minsize")));
                pds.setSleepTime(Long.parseLong(jotmJdbcElement.getAttribute("pool-sleeptime")));
                pds.setLifeTime(Long.parseLong(jotmJdbcElement.getAttribute("pool-lifetime")));
                pds.setDeadLockMaxWait(Long.parseLong(jotmJdbcElement.getAttribute("pool-deadlock-maxwait")));
                pds.setDeadLockRetryWait(Long.parseLong(jotmJdbcElement.getAttribute("pool-deadlock-retrywait")));

                // set the test statement to test connections
                String testStmt = jotmJdbcElement.getAttribute("pool-jdbc-test-stmt");
                if (testStmt != null && testStmt.length() > 0) {
                    pds.setJdbcTestStmt(testStmt);
                    Debug.logInfo("Set JDBC Test Statement : " + testStmt, module);
                }
            } catch (NumberFormatException nfe) {
                Debug.logError(nfe, "Problems with pool settings; the values MUST be numbers, using defaults.", module);
            } catch (Exception e) {
                Debug.logError(e, "Problems with pool settings", module);
            }

            // cache the pool
            dsCache.put(helperName, pds);

            return TransactionFactory.getCursorConnection(helperName, pds.getConnection());
        }
    }
View Full Code Here

Examples of org.enhydra.jdbc.pool.StandardXAPoolDataSource

    public static void closeAll() {
        Set cacheKeys = dsCache.keySet();
        Iterator i = cacheKeys.iterator();
        while (i.hasNext()) {
            String helperName = (String) i.next();
            StandardXAPoolDataSource pds = (StandardXAPoolDataSource) dsCache.remove(helperName);
            pds.shutdown(true);
        }
    }
View Full Code Here

Examples of org.enhydra.jdbc.pool.StandardXAPoolDataSource

                        "messageCorrelationId varchar(96) NOT NULL, " +
                        "messageContent varchar(2048) NOT NULL, " +
                        "PRIMARY KEY (id) )";

        java.sql.Connection conn = null;
        StandardXAPoolDataSource pool = getMandatoryBean(StandardXAPoolDataSource.class, "jdbcEnhydraXaDataSource");
        conn = pool.getConnection();
        try {
            conn.createStatement().execute(createStatement);
        } catch (SQLException alreadyExists) {
            log.info("ex on create tables", alreadyExists);
        }
View Full Code Here

Examples of org.enhydra.jdbc.pool.StandardXAPoolDataSource

    public static final String module = XaPoolConnectionFactory.class.getName();

    protected static Map dsCache = new HashMap();

    public static Connection getConnection(String helperName, Element jdbcElement) throws SQLException, GenericEntityException {
        StandardXAPoolDataSource pds = (StandardXAPoolDataSource) dsCache.get(helperName);
        if (pds != null) {
            if (Debug.verboseOn()) Debug.logVerbose(helperName + " pool size: " + pds.pool.getCount(), module);
            return TransactionFactory.getCursorConnection(helperName, pds.getConnection());
        }

        synchronized (XaPoolConnectionFactory.class) {
            pds = (StandardXAPoolDataSource) dsCache.get(helperName);
            if (pds != null) {
                return pds.getConnection();
            }

            // the xapool wrapper class
            String wrapperClass = jdbcElement.getAttribute("pool-xa-wrapper-class");

            StandardXADataSource ds = null;
            try {
                //ds =  new StandardXADataSource();
                ds = (StandardXADataSource) ObjectType.getInstance(wrapperClass);
                pds = new StandardXAPoolDataSource();
            } catch (NoClassDefFoundError e) {
                throw new GenericEntityException("Cannot find xapool.jar");
            } catch (ClassNotFoundException e) {
                throw new GenericEntityException("Cannot load wrapper class: " + wrapperClass, e);
            } catch (InstantiationException e) {
                throw new GenericEntityException("Unable to instantiate " + wrapperClass, e);
            } catch (IllegalAccessException e) {
                throw new GenericEntityException("Problems getting instance of " + wrapperClass, e);
            }

            if (ds == null)
                throw new GenericEntityException("StandardXaDataSource was not created, big problem!");

            ds.setDriverName(jdbcElement.getAttribute("jdbc-driver"));
            ds.setUrl(jdbcElement.getAttribute("jdbc-uri"));
            ds.setUser(jdbcElement.getAttribute("jdbc-username"));
            ds.setPassword(jdbcElement.getAttribute("jdbc-password"));
            ds.setDescription(helperName);
            ds.setTransactionManager(TransactionFactory.getTransactionManager());

            String transIso = jdbcElement.getAttribute("isolation-level");
            if (UtilValidate.isNotEmpty(transIso)) {
                if ("Serializable".equals(transIso)) {
                    ((StandardXADataSource) ds).setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
                } else if ("RepeatableRead".equals(transIso)) {
                    ((StandardXADataSource) ds).setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
                } else if ("ReadUncommitted".equals(transIso)) {
                    ((StandardXADataSource) ds).setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
                } else if ("ReadCommitted".equals(transIso)) {
                    ((StandardXADataSource) ds).setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
                } else if ("None".equals(transIso)) {
                    ((StandardXADataSource) ds).setTransactionIsolation(Connection.TRANSACTION_NONE);
                }
            }

            // set the datasource in the pool
            pds.setDataSource(ds);
            pds.setDescription(ds.getDescription());
            pds.setUser(ds.getUser());
            pds.setPassword(ds.getPassword());
            Debug.logInfo("XADataSource: " + ds.getClass().getName() + " attached to pool.", module);

            // set the transaction manager in the pool
            pds.setTransactionManager(TransactionFactory.getTransactionManager());

            // configure the pool settings
            try {
                pds.setMaxSize(Integer.parseInt(jdbcElement.getAttribute("pool-maxsize")));
                pds.setMinSize(Integer.parseInt(jdbcElement.getAttribute("pool-minsize")));
                pds.setSleepTime(Long.parseLong(jdbcElement.getAttribute("pool-sleeptime")));
                pds.setLifeTime(Long.parseLong(jdbcElement.getAttribute("pool-lifetime")));
                pds.setDeadLockMaxWait(Long.parseLong(jdbcElement.getAttribute("pool-deadlock-maxwait")));
                pds.setDeadLockRetryWait(Long.parseLong(jdbcElement.getAttribute("pool-deadlock-retrywait")));

                // set the test statement to test connections
                String testStmt = jdbcElement.getAttribute("pool-jdbc-test-stmt");
                if (UtilValidate.isNotEmpty(testStmt)) {
                    pds.setJdbcTestStmt(testStmt);
                    Debug.logInfo("Set JDBC Test Statement : " + testStmt, module);
                }
            } catch (NumberFormatException nfe) {
                Debug.logError(nfe, "Problems with pool settings; the values MUST be numbers, using defaults.", module);
            } catch (Exception e) {
                Debug.logError(e, "Problems with pool settings", module);
            }

            // cache the pool
            dsCache.put(helperName, pds);

            return TransactionFactory.getCursorConnection(helperName, pds.getConnection());
        }
    }
View Full Code Here

Examples of org.enhydra.jdbc.pool.StandardXAPoolDataSource

    public static void closeAll() {
        Set cacheKeys = dsCache.keySet();
        Iterator i = cacheKeys.iterator();
        while (i.hasNext()) {
            String helperName = (String) i.next();
            StandardXAPoolDataSource pds = (StandardXAPoolDataSource) dsCache.remove(helperName);
            pds.shutdown(true);
        }
    }
View Full Code Here

Examples of org.enhydra.jdbc.pool.StandardXAPoolDataSource

    public static final String module = XaPoolConnectionFactory.class.getName();               
       
    protected static Map dsCache = new HashMap();
   
    public static Connection getConnection(String helperName, Element jotmJdbcElement) throws SQLException, GenericEntityException {                              
        StandardXAPoolDataSource pds = (StandardXAPoolDataSource) dsCache.get(helperName);       
        if (pds != null) {                     
            if (Debug.verboseOn()) Debug.logVerbose(helperName + " pool size: " + pds.pool.getCount(), module);          
            return TransactionFactory.getCursorConnection(helperName, pds.getConnection());
        }
       
        synchronized (XaPoolConnectionFactory.class) {           
            pds = (StandardXAPoolDataSource) dsCache.get(helperName);
            if (pds != null) {                          
                return pds.getConnection();
            }
           
            // the xapool wrapper class
            String wrapperClass = jotmJdbcElement.getAttribute("pool-xa-wrapper-class");
           
            StandardXADataSource ds = null;        
            try {           
                //ds =  new StandardXADataSource();               
                ds = (StandardXADataSource) ObjectType.getInstance(wrapperClass);
                pds = new StandardXAPoolDataSource();
            } catch (NoClassDefFoundError e) {               
                throw new GenericEntityException("Cannot find xapool.jar");                      
            } catch (ClassNotFoundException e) {
                throw new GenericEntityException("Cannot load wrapper class: " + wrapperClass, e);               
            } catch (InstantiationException e) {
                throw new GenericEntityException("Unable to instantiate " + wrapperClass, e);               
            } catch (IllegalAccessException e) {
                throw new GenericEntityException("Problems getting instance of " + wrapperClass, e);               
            }
           
            if (ds == null)
                throw new GenericEntityException("StandardXaDataSource was not created, big problem!");
           
            ds.setDriverName(jotmJdbcElement.getAttribute("jdbc-driver"));
            ds.setUrl(jotmJdbcElement.getAttribute("jdbc-uri"));
            ds.setUser(jotmJdbcElement.getAttribute("jdbc-username"));
            ds.setPassword(jotmJdbcElement.getAttribute("jdbc-password"));
            ds.setDescription(helperName)
            ds.setTransactionManager(TransactionFactory.getTransactionManager());
           
            String transIso = jotmJdbcElement.getAttribute("isolation-level");
            if (transIso != null && transIso.length() > 0) {
                if ("Serializable".equals(transIso)) {
                    ((StandardXADataSource) ds).setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
                } else if ("RepeatableRead".equals(transIso)) {
                    ((StandardXADataSource) ds).setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
                } else if ("ReadUncommitted".equals(transIso)) {
                    ((StandardXADataSource) ds).setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
                } else if ("ReadCommitted".equals(transIso)) {
                    ((StandardXADataSource) ds).setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
                } else if ("None".equals(transIso)) {
                    ((StandardXADataSource) ds).setTransactionIsolation(Connection.TRANSACTION_NONE);
                }                                           
            }
           
            // set the datasource in the pool           
            pds.setDataSource(ds);
            pds.setDescription(ds.getDescription());
            pds.setUser(ds.getUser());
            pds.setPassword(ds.getPassword());
            Debug.logInfo("XADataSource: " + ds.getClass().getName() + " attached to pool.", module);
           
            // set the transaction manager in the pool
            pds.setTransactionManager(TransactionFactory.getTransactionManager());
           
            // configure the pool settings          
            try {           
                pds.setMaxSize(new Integer(jotmJdbcElement.getAttribute("pool-maxsize")).intValue());
                pds.setMinSize(new Integer(jotmJdbcElement.getAttribute("pool-minsize")).intValue());
                pds.setSleepTime(new Long(jotmJdbcElement.getAttribute("pool-sleeptime")).longValue());
                pds.setLifeTime(new Long(jotmJdbcElement.getAttribute("pool-lifetime")).longValue());
                pds.setDeadLockMaxWait(new Long(jotmJdbcElement.getAttribute("pool-deadlock-maxwait")).longValue());
                pds.setDeadLockRetryWait(new Long(jotmJdbcElement.getAttribute("pool-deadlock-retrywait")).longValue());
               
                // set the test statement to test connections
                String testStmt = jotmJdbcElement.getAttribute("pool-jdbc-test-stmt");
                if (testStmt != null && testStmt.length() > 0) {
                    pds.setJdbcTestStmt(testStmt);
                    Debug.logInfo("Set JDBC Test Statement : " + testStmt, module);
                }               
            } catch (NumberFormatException nfe) {
                Debug.logError(nfe, "Problems with pool settings; the values MUST be numbers, using defaults.", module);
            } catch (Exception e) {
                Debug.logError(e, "Problems with pool settings", module);
            }
                                 
            // cache the pool
            dsCache.put(helperName, pds);       
                                                     
            return TransactionFactory.getCursorConnection(helperName, pds.getConnection());
        }               
    }
View Full Code Here

Examples of org.enhydra.jdbc.pool.StandardXAPoolDataSource

    public static void closeAll() {
        Set cacheKeys = dsCache.keySet();
        Iterator i = cacheKeys.iterator();
        while (i.hasNext()) {
            String helperName = (String) i.next();
            StandardXAPoolDataSource pds = (StandardXAPoolDataSource) dsCache.remove(helperName);
            pds.shutdown(true);  
        }                                                                            
    }
View Full Code Here

Examples of org.enhydra.jdbc.pool.StandardXAPoolDataSource

      ds.setPassword(props.get("connection.password"));
      // ds.setMinCon(Integer.parseInt(props.get("connection.min-size"))) ;
      // ds.setMaxCon(Integer.parseInt(props.get("connection.max-size"))) ;
      ds.setTransactionManager(txService_.getTransactionManager());

      StandardXAPoolDataSource pool = new StandardXAPoolDataSource(3);
      pool.setMinSize(Integer.parseInt(props.get("connection.min-size")));
      pool.setMaxSize(Integer.parseInt(props.get("connection.max-size")));
      pool.setUser(props.get("connection.login"));
      pool.setPassword(props.get("connection.password"));
      pool.setDataSource(ds);
      return pool;
   }
View Full Code Here

Examples of org.enhydra.jdbc.pool.StandardXAPoolDataSource

      ds.setPassword(props.get("connection.password"));
      // ds.setMinCon(Integer.parseInt(props.get("connection.min-size"))) ;
      // ds.setMaxCon(Integer.parseInt(props.get("connection.max-size"))) ;
      ds.setTransactionManager(txService_.getTransactionManager());

      StandardXAPoolDataSource pool = new StandardXAPoolDataSource(3);
      pool.setMinSize(Integer.parseInt(props.get("connection.min-size")));
      pool.setMaxSize(Integer.parseInt(props.get("connection.max-size")));
      pool.setUser(props.get("connection.login"));
      pool.setPassword(props.get("connection.password"));
      pool.setDataSource(ds);
      return pool;
   }
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.