Package bitronix.tm.resource.jdbc

Examples of bitronix.tm.resource.jdbc.PoolingDataSource


        TransactionManagerServices.getTransactionManager();

        MockitoXADataSource.setStaticCloseXAConnectionException(null);
        MockitoXADataSource.setStaticGetXAConnectionException(null);

        pds = new PoolingDataSource();
        pds.setMinPoolSize(1);
        pds.setMaxPoolSize(2);
        pds.setMaxIdleTime(1);
        pds.setClassName(MockitoXADataSource.class.getName());
        pds.setUniqueName("pds");
View Full Code Here


    }

    public void testInitFailure() throws Exception {
        pds.close();

        pds = new PoolingDataSource();
        pds.setMinPoolSize(0);
        pds.setMaxPoolSize(2);
        pds.setMaxIdleTime(1);
        pds.setClassName(MockitoXADataSource.class.getName());
        pds.setUniqueName("pds");
View Full Code Here

    public void testPoolNotStartingTransactionManager() throws Exception {
        // make sure TM is not running
        TransactionManagerServices.getTransactionManager().shutdown();
       
        PoolingDataSource pds = new PoolingDataSource();
        pds.setMinPoolSize(1);
        pds.setMaxPoolSize(2);
        pds.setMaxIdleTime(1);
        pds.setClassName(MockitoXADataSource.class.getName());
        pds.setUniqueName("pds2");
        pds.setAllowLocalTransactions(true);
        pds.setAcquisitionTimeout(1);
        pds.init();

        assertFalse(TransactionManagerServices.isTransactionManagerRunning());

        Connection c = pds.getConnection();
        Statement stmt = c.createStatement();
        stmt.close();
        c.close();

        assertFalse(TransactionManagerServices.isTransactionManagerRunning());

        pds.close();

        assertFalse(TransactionManagerServices.isTransactionManagerRunning());
    }
View Full Code Here

            pds.close();
        }
    }

    protected static PoolingDataSource setupPoolingDataSource() {
        PoolingDataSource pds = new PoolingDataSource();
        pds.setUniqueName("jdbc/jbpm-ds");
        pds.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource");
        pds.setMaxPoolSize(50);
        pds.setAllowLocalTransactions(true);
        pds.getDriverProperties().put("user", "sa");
        pds.getDriverProperties().put("password", "");
        pds.getDriverProperties().put("url", "jdbc:h2:mem:jbpm-db;MVCC=true");
        pds.getDriverProperties().put("driverClassName", "org.h2.Driver");
        pds.init();
        return pds;
    }
View Full Code Here

    }

    public static PoolingDataSource setupPoolingDataSource() {
        Properties dsProps = getDatasourceProperties();

        PoolingDataSource pds = new PoolingDataSource();

        // The name must match what's in the persistence.xml!
        pds.setUniqueName("jdbc/testDS1");

        pds.setClassName(dsProps.getProperty("className"));

        pds.setMaxPoolSize(Integer.parseInt(dsProps.getProperty("maxPoolSize")));
        pds.setAllowLocalTransactions(Boolean.parseBoolean(dsProps
                .getProperty("allowLocalTransactions")));
        for (String propertyName : new String[] { "user", "password" }) {
            pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
        }

        String driverClass = dsProps.getProperty("driverClassName");
        if (driverClass.startsWith("org.h2")) {
            h2Server.start();
            for (String propertyName : new String[] { "url", "driverClassName" }) {
                pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
            }
        }
        else {
            pds.setClassName(dsProps.getProperty("className"));
           
            if( driverClass.startsWith("oracle") ) {
              pds.getDriverProperties().put("driverType", "thin");
              pds.getDriverProperties().put("URL", dsProps.getProperty("url"));
          }
          else if( driverClass.startsWith("com.ibm.db2") ) {
              // placeholder for eventual future modifications
          }
          else if( driverClass.startsWith("com.microsoft") ) {
              for (String propertyName : new String[] { "serverName", "portNumber", "databaseName" }) {
                  pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
              }
              pds.getDriverProperties().put("URL", dsProps.getProperty("url"));
              pds.getDriverProperties().put("selectMethod", "cursor");
              pds.getDriverProperties().put("InstanceName", "MSSQL01");
              // pds.getDriverProperties().put("instanceName", dsProps.getProperty("databaseName"));
              // do nothing
              // pds.getDriverProperties().put("instanceName", "mssql");
          }
          else if( driverClass.startsWith("com.mysql") ) {
              for (String propertyName : new String[] { "databaseName", "serverName", "portNumber", "url" }) {
                  pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
              }
          }
          else if( driverClass.startsWith("com.sybase") ) {
              for (String propertyName : new String[] { "databaseName", "portNumber", "serverName" }) {
                  pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
              }
              pds.getDriverProperties().put("REQUEST_HA_SESSION", "false");
              pds.getDriverProperties().put("networkProtocol", "Tds");
          }
          else if( driverClass.startsWith("org.postgresql") ) {
              for (String propertyName : new String[] { "databaseName", "portNumber", "serverName" }) {
                  pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
              }
          }
          else {
              throw new RuntimeException("Unknown driver class: " + driverClass);
          }
View Full Code Here

        String jdbcURLBase = dsProps.getProperty("url");
        // trace level file = 0 means that modifying the inode of the db file will _not_ cause a "corrupted" exception
        String jdbcUrl =  jdbcURLBase + dbFilePath;
       
        // Setup the datasource
        PoolingDataSource ds1 = setupPoolingDataSource(dsProps);
        ds1.getDriverProperties().setProperty("url", jdbcUrl );
        ds1.init();
        context.put(DATASOURCE, ds1);
   
        // Setup persistence
        Properties overrideProperties = new Properties();
        overrideProperties.setProperty("hibernate.connection.url", jdbcUrl);
View Full Code Here

               
            jdbcUrl = initializeTestDb(dsProps, testClass);
        }

        // Setup the datasource
        PoolingDataSource ds1 = setupPoolingDataSource(dsProps, dataSourceName);
        if( driverClass.startsWith("org.h2") ) {
            if( ! TEST_MARSHALLING ) {
                jdbcUrl += "tcp://localhost/JPADroolsFlow";
            }
            ds1.getDriverProperties().setProperty("url", jdbcUrl);
        }
        ds1.init();
        context.put(DATASOURCE, ds1);

        // Setup persistence
        EntityManagerFactory emf;
        if (TEST_MARSHALLING) {
View Full Code Here

            }

            Object ds1Object = context.remove(DATASOURCE);
            if (ds1Object != null) {
                try {
                    PoolingDataSource ds1 = (PoolingDataSource) ds1Object;
                    ds1.close();
                } catch (Throwable t) {
                    t.printStackTrace();
                }
            }
           
View Full Code Here

     * This sets up a Bitronix PoolingDataSource.
     *
     * @return PoolingDataSource that has been set up but _not_ initialized.
     */
    public static PoolingDataSource setupPoolingDataSource(Properties dsProps, String datasourceName) {
        PoolingDataSource pds = new PoolingDataSource();

        // The name must match what's in the persistence.xml!
        pds.setUniqueName(datasourceName);

        pds.setClassName(dsProps.getProperty("className"));

        pds.setMaxPoolSize(Integer.parseInt(dsProps.getProperty("maxPoolSize")));
        pds.setAllowLocalTransactions(Boolean.parseBoolean(dsProps
                .getProperty("allowLocalTransactions")));
        for (String propertyName : new String[] { "user", "password" }) {
            pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
        }

        String driverClass = dsProps.getProperty("driverClassName");
        if (driverClass.startsWith("org.h2")) {
            if( ! TEST_MARSHALLING ) {
                h2Server.start();
            }
            for (String propertyName : new String[] { "url", "driverClassName" }) {
                pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
            }
        } else {
            pds.setClassName(dsProps.getProperty("className"));

            if (driverClass.startsWith("oracle")) {
                pds.getDriverProperties().put("driverType", "thin");
                pds.getDriverProperties().put("URL", dsProps.getProperty("url"));
            } else if (driverClass.startsWith("com.ibm.db2")) {
                // http://docs.codehaus.org/display/BTM/JdbcXaSupportEvaluation#JdbcXaSupportEvaluation-IBMDB2
                pds.getDriverProperties().put("databaseName", dsProps.getProperty("databaseName"));
                pds.getDriverProperties().put("driverType", "4");
                pds.getDriverProperties().put("serverName", dsProps.getProperty("serverName"));
                pds.getDriverProperties().put("portNumber", dsProps.getProperty("portNumber"));
            } else if (driverClass.startsWith("com.microsoft")) {
                for (String propertyName : new String[] { "serverName", "portNumber", "databaseName" }) {
                    pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
                }
                pds.getDriverProperties().put("URL", dsProps.getProperty("url"));
                pds.getDriverProperties().put("selectMethod", "cursor");
                pds.getDriverProperties().put("InstanceName", "MSSQL01");
            } else if (driverClass.startsWith("com.mysql")) {
                for (String propertyName : new String[] { "databaseName", "serverName", "portNumber", "url" }) {
                    pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
                }
            } else if (driverClass.startsWith("com.sybase")) {
                for (String propertyName : new String[] { "databaseName", "portNumber", "serverName" }) {
                    pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
                }
                pds.getDriverProperties().put("REQUEST_HA_SESSION", "false");
                pds.getDriverProperties().put("networkProtocol", "Tds");
            } else if (driverClass.startsWith("org.postgresql")) {
                for (String propertyName : new String[] { "databaseName", "portNumber", "serverName" }) {
                    pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
                }
            } else {
                throw new RuntimeException("Unknown driver class: " + driverClass);
            }
        }
View Full Code Here

               
            jdbcUrl = initializeTestDb(dsProps, testClass);
        }

        // Setup the datasource
        PoolingDataSource ds1 = setupPoolingDataSource(dsProps, dataSourceName);
        if( driverClass.startsWith("org.h2") ) {
            if( ! TEST_MARSHALLING ) {
                jdbcUrl += "tcp://localhost/JPADroolsFlow";
            }
            ds1.getDriverProperties().setProperty("url", jdbcUrl);
        }
        ds1.init();
        context.put(DATASOURCE, ds1);

        // Setup persistence
        EntityManagerFactory emf;
        if (TEST_MARSHALLING) {
View Full Code Here

TOP

Related Classes of bitronix.tm.resource.jdbc.PoolingDataSource

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.