Package net.sf.hajdbc.sql

Examples of net.sf.hajdbc.sql.DataSource


    config.setDatabaseMetaDataCacheFactory(new SimpleDatabaseMetaDataCacheFactory());
    config.setStateManagerFactory(factory);
//    config.setDispatcherFactory(new JGroupsCommandDispatcherFactory());
    config.setDurabilityFactory(new FineDurabilityFactory());

    DataSource ds = new DataSource();
    ds.setCluster("cluster");
    ds.setConfigurationFactory(new SimpleDatabaseClusterConfigurationFactory<javax.sql.DataSource, DataSourceDatabase>(config));
   
    InvocationHandler<javax.sql.DataSource, DataSourceDatabase, javax.sql.DataSource, SQLException, ProxyFactory<javax.sql.DataSource, DataSourceDatabase, javax.sql.DataSource, SQLException>> handler = (InvocationHandler<javax.sql.DataSource, DataSourceDatabase, javax.sql.DataSource, SQLException, ProxyFactory<javax.sql.DataSource, DataSourceDatabase, javax.sql.DataSource, SQLException>>) Proxy.getInvocationHandler(ds.getProxy());
    ProxyFactory<javax.sql.DataSource, DataSourceDatabase, javax.sql.DataSource, SQLException> proxyFactory = handler.getProxyFactory();

    try
    {
      Connection c1 = proxyFactory.get(db1).getConnection();
      try
      {
        createTable(c1);
       
        try
        {
          Connection c2 = proxyFactory.get(db2).getConnection();
          try
          {
            createTable(c2);
           
            try
            {
              Connection c = ds.getConnection();
              try
              {
                c.setAutoCommit(false);
                PreparedStatement ps = c.prepareStatement("INSERT INTO test (id, name) VALUES (?, ?)");
                try
                {
                  ps.setInt(1, 1);
                  ps.setString(2, "1");
                  ps.addBatch();
                  ps.setInt(1, 2);
                  ps.setString(2, "2");
                  ps.addBatch();
                  ps.executeBatch();
                }
                finally
                {
                  Resources.close(ps);
                }
                c.commit();
               
                validate(c1);
                validate(c2);
              }
              finally
              {
                Resources.close(c);
              }
            }
            finally
            {
              dropTable(c2);
            }
          }
          finally
          {
            c2.close();
          }
        }
        finally
        {
          dropTable(c1);
        }
      }
      finally
      {
        c1.close();
      }
    }
    finally
    {
      ds.stop();
    }
  }
View Full Code Here


    config.setDatabaseMetaDataCacheFactory(new SimpleDatabaseMetaDataCacheFactory());
    config.setStateManagerFactory(factory);
//    config.setDispatcherFactory(new JGroupsCommandDispatcherFactory());
    config.setDurabilityFactory(new FineDurabilityFactory());

    DataSource ds = new DataSource();
    ds.setCluster("cluster");
    ds.setConfigurationFactory(new SimpleDatabaseClusterConfigurationFactory<javax.sql.DataSource, DataSourceDatabase>(config));
   
    @SuppressWarnings("unchecked")
    InvocationHandler<javax.sql.DataSource, DataSourceDatabase, javax.sql.DataSource, SQLException, ProxyFactory<javax.sql.DataSource, DataSourceDatabase, javax.sql.DataSource, SQLException>> handler = (InvocationHandler<javax.sql.DataSource, DataSourceDatabase, javax.sql.DataSource, SQLException, ProxyFactory<javax.sql.DataSource, DataSourceDatabase, javax.sql.DataSource, SQLException>>) Proxy.getInvocationHandler(ds.getProxy());
    ProxyFactory<javax.sql.DataSource, DataSourceDatabase, javax.sql.DataSource, SQLException> proxyFactory = handler.getProxyFactory();

    try
    {
      Connection c1 = proxyFactory.get(db1).getConnection();
      try
      {
        this.createTable(c1);
        try
        {
          Connection c2 = proxyFactory.get(db2).getConnection();
          try
          {
            this.createTable(c2);
           
            try
            {
              Connection c = ds.getConnection();
              try
              {
                c.setAutoCommit(false);
                PreparedStatement ps = c.prepareStatement("INSERT INTO test (id, name) VALUES (?, ?)");
                try
                {
                  ps.setInt(1, 1);
                  ps.setString(2, "1");
                  ps.addBatch();
                  ps.setInt(1, 2);
                  ps.setString(2, "2");
                  ps.addBatch();
                  ps.executeBatch();
                }
                finally
                {
                  Resources.close(ps);
                }
                c.commit();
               
                this.validate(c1);
                this.validate(c2);
              }
              finally
              {
                Resources.close(c);
              }
            }
            finally
            {
              this.dropTable(c2);
            }
          }
          finally
          {
            c2.close();
          }
        }
        finally
        {
          this.dropTable(c1);
        }
      }
      finally
      {
        c1.close();
      }
    }
    finally
    {
      ds.stop();
    }
  }
View Full Code Here

    config.setDatabaseMetaDataCacheFactory(new SimpleDatabaseMetaDataCacheFactory());
    config.setStateManagerFactory(factory);
//    config.setDispatcherFactory(new JGroupsCommandDispatcherFactory());
    config.setDurabilityFactory(new FineDurabilityFactory());

    DataSource ds = new DataSource();
    ds.setCluster("cluster");
    ds.setConfigurationFactory(new SimpleDatabaseClusterConfigurationFactory<javax.sql.DataSource, DataSourceDatabase>(config));
   
    InvocationHandler<javax.sql.DataSource, DataSourceDatabase, javax.sql.DataSource, SQLException, ProxyFactory<javax.sql.DataSource, DataSourceDatabase, javax.sql.DataSource, SQLException>> handler = (InvocationHandler<javax.sql.DataSource, DataSourceDatabase, javax.sql.DataSource, SQLException, ProxyFactory<javax.sql.DataSource, DataSourceDatabase, javax.sql.DataSource, SQLException>>) Proxy.getInvocationHandler(ds.getProxy());
    ProxyFactory<javax.sql.DataSource, DataSourceDatabase, javax.sql.DataSource, SQLException> proxyFactory = handler.getProxyFactory();

    try
    {
      Connection c1 = proxyFactory.get(db1).getConnection();
      try
      {
        createTable(c1);
       
        try
        {
          Connection c2 = proxyFactory.get(db2).getConnection();
          try
          {
            createTable(c2);
           
            try
            {
              Connection c = ds.getConnection();
              try
              {
                c.setAutoCommit(false);
                PreparedStatement ps = c.prepareStatement("INSERT INTO test (id, name) VALUES (?, ?)");
                try
                {
                  ps.setInt(1, 1);
                  ps.setString(2, "1");
                  ps.addBatch();
                  ps.setInt(1, 2);
                  ps.setString(2, "2");
                  ps.addBatch();
                  ps.executeBatch();
                }
                finally
                {
                  Resources.close(ps);
                }
                c.commit();
               
                validate(c1);
                validate(c2);
              }
              finally
              {
                Resources.close(c);
              }
            }
            finally
            {
              dropTable(c2);
            }
          }
          finally
          {
            c2.close();
          }
        }
        finally
        {
          dropTable(c1);
        }
      }
      finally
      {
        c1.close();
      }
    }
    finally
    {
      ds.stop();
    }
  }
View Full Code Here

TOP

Related Classes of net.sf.hajdbc.sql.DataSource

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.