Examples of DBPool


Examples of com.caucho.sql.DBPool

  @Override
  public DataSource create()
  {
    Class<?> driverClass = getDriverClass();
   
    DBPool pool = new DBPool();
    pool.setName(getName());
   
    DriverConfig driver = pool.createDriver();
    driver.setType(driverClass);
   
    ConfigType<?> configType = TypeFactory.getType(driverClass);

    if (getUrl() != null) {
      if (configType.getAttribute(URL) != null
          || Driver.class.isAssignableFrom(driverClass)) {
        driver.setURL(getUrl());
      }
    }

    if (getDatabaseName() != null) {
      driver.setProperty("database-name", getDatabaseName());
    }
   
    if (getUser() != null)
      driver.setUser(getUser());
   
    if (getPassword() != null)
      driver.setPassword(getPassword());
   
    try {
      driver.init();
     
      pool.init();
    } catch (Exception e) {
      e.printStackTrace();
      throw ConfigException.create(e);
    }
   
View Full Code Here

Examples of de.mhus.lib.sql.DbPool

   
    public void testGet() throws Exception {
     
      DbPoolBundle bundle = createPool();
     
      DbPool pool = bundle.getPool("test");
      assertEquals(0, pool.getSize());
     
      DbConnection con1 = pool.getConnection();
      assertEquals(1, pool.getSize());
     
      DbConnection con2 = pool.getConnection();
      assertEquals(2, pool.getSize());
     
      con1.close();
      pool.cleanup(false);
      assertEquals(2, pool.getSize());
      pool.cleanup(true);
      assertEquals(1, pool.getSize());
     
      DbConnection con3 = pool.getConnection();
      assertEquals(2, pool.getSize());
      con3.close();
     
      pool.cleanup(true);
      assertEquals(1, pool.getSize());

      con2.close();
      pool.cleanup(true);
      assertEquals(0, pool.getSize());
     
    }
View Full Code Here

Examples of de.mhus.lib.sql.DbPool

      assertEquals(0, pool.getSize());
     
    }

    public void testConnect() throws Exception {
      DbPool pool = createPool().getPool("test");
      DbConnection con = pool.getConnection();
     
      // create database
      DbStatement sthc = con.getStatement("create");
      try {
        sthc.executeUpdate(null);
View Full Code Here

Examples of de.mhus.lib.sql.DbPool

      con.commit();

    }
   
    public void testAttributes() throws IOException, Exception {
      DbPool pool = createPool().getPool("test");
      DbConnection con = pool.getConnection();
      try {
        con.getStatement("cleanup").execute(null);
          con.commit();
      } catch (ClassNotFoundException e1) {
        System.out.println("testAttributes: sql driver not found - skip test");
View Full Code Here

Examples of de.mhus.lib.sql.DbPool

    }
   
    @SuppressWarnings("deprecation")
  public void testAttributes2() throws IOException, Exception {
      DbPool pool = createPool().getPool("test");
      DbConnection con = pool.getConnection();
      try {
        con.getStatement("cleanup2").execute(null);
          con.commit();
      } catch (ClassNotFoundException e1) {
        System.out.println("testAttributes: sql driver not found - skip test");
View Full Code Here

Examples of de.mhus.lib.sql.DbPool

    }
   
    public void testStructure() throws Exception {
     
      DbPool pool = createPool().getPool("test");
      DbConnection con = pool.getConnection();
     
      try {
        con.getStatement("cleanup").execute(null);
          con.commit();
      } catch (ClassNotFoundException e1) {
        System.out.println("testStructure: sql driver not found - skip test");
        return;
      } catch (SQLException e2) {
        if (e2.getMessage().startsWith("Communications link failure")) {
          System.out.println("testStructure: mysql db not found - skip test");
          return;
        } else {
          throw e2;
        }
      }
     
      con.getStatement("dropblub").execute(null);
     
      HashConfig cstr = new HashConfig();
      IConfig ctable = cstr.createConfig("table");
      ctable.setProperty("name", "blub");
      IConfig cfield = ctable.createConfig("field");
      cfield.setProperty("name", "t_string");
      cfield.setProperty("type", "string");
      cfield.setProperty("size", "200");
      cfield.setProperty("default", "aloa");
     
      Dialect dialect = pool.getDialect();
      System.out.println("--------------------------------------------------");
      dialect.createStructure(cstr, con, null);     
      dialect.createStructure(cstr, con, null);

      cfield = ctable.createConfig("field");
      cfield.setProperty("name", "t_int");
      cfield.setProperty("type", "int");
      cfield.setProperty("default", "10");
     
      System.out.println("--------------------------------------------------");
      dialect.createStructure(cstr, con, null);
      dialect.createStructure(cstr, con, null);
     
      cfield.setProperty("type", "float");
     
      System.out.println("--------------------------------------------------");
      dialect.createStructure(cstr, con, null);
      dialect.createStructure(cstr, con, null);
     
      cfield.setProperty("default", "20");
     
      System.out.println("--------------------------------------------------");
      dialect.createStructure(cstr, con, null);
      dialect.createStructure(cstr, con, null);
     
      cfield.removeProperty("default");
     
      System.out.println("--------------------------------------------------");
      dialect.createStructure(cstr, con, null);
      dialect.createStructure(cstr, con, null);
     
      cfield.setProperty("default", "15");
     
      System.out.println("--------------------------------------------------");
      dialect.createStructure(cstr, con, null);
      dialect.createStructure(cstr, con, null);

      cfield.setProperty("notnull", "yes");
     
      System.out.println("--------------------------------------------------");
      dialect.createStructure(cstr, con, null);
      dialect.createStructure(cstr, con, null);
     
      ctable.setProperty("primary_key", "t_int");
     
      dialect.createStructure(cstr, con, null);
      dialect.createStructure(cstr, con, null);
     
      ctable.setProperty("primary_key", "t_int,t_string");
     
      System.out.println("--------------------------------------------------");
      dialect.createStructure(cstr, con, null);
      dialect.createStructure(cstr, con, null);
     
      ctable.removeProperty("primary_key");
     
      System.out.println("--------------------------------------------------");
      dialect.createStructure(cstr, con, null);
      dialect.createStructure(cstr, con, null);
     
     
      // index
     
      IConfig cindex = cstr.createConfig("index");
      cindex.setString("name", "blub_idx");
      cindex.setString("table", "blub");
      cindex.setString("fields", "t_string");
     
      System.out.println("--------------------------------------------------");
      dialect.createStructure(cstr, con, null);
      dialect.createStructure(cstr, con, null);

      cindex.setString("fields", "t_string,t_int");
     
      System.out.println("--------------------------------------------------");
      dialect.createStructure(cstr, con, null);
      dialect.createStructure(cstr, con, null);
     
      // data
      IConfig cdata = cstr.createConfig("data");
      IConfig cexec = cdata.createConfig("execute");
      String tName = pool.getDialect().normalizeTableName("blub");
      cexec.setProperty("sql", "insert into " + tName + " (t_string,t_int) values ('aaa',1)");
      cexec = cdata.createConfig("execute");
      cexec.setProperty("sql", "insert into " + tName + " (t_string,t_int) values ('bbb',2)");
     
      System.out.println("--------------------------------------------------");
View Full Code Here

Examples of de.mhus.lib.sql.DbPool

    }
   
    @SuppressWarnings("unused")
  public void testModel() throws Throwable {
     
      DbPool pool = createPool().getPool("test");
     
      BookStoreSchema schema = new BookStoreSchema();
     
      MStopWatch timer = new MStopWatch();
      timer.start();
View Full Code Here

Examples of de.mhus.lib.sql.DbPool

    super(driver,form.getConfig(),form.getActivator());
   
    setUser( new CaoUser(new EmptyApplication(this),System.getProperty("user.name"),true,true) ); // TODO Maybe change this
   
    this.form = form;
    pool = new DbPool(getConfig().getConfig("database"),form.getActivator());
    initDatabase();
  }
View Full Code Here

Examples of de.mhus.lib.sql.DbPool

      // pool
     
      System.out.println(ConfigUtil.toString(config));
     
      DbPool pool = new DbPool(config.getConfig("database"), null);
     
    // create database
    BlubSchema schema = new BlubSchema();
    DbManager manager = new DbManager(pool, schema);
   
View Full Code Here

Examples of de.mhus.lib.sql.DbPool

      // pool
     
      System.out.println(ConfigUtil.toString(config));
     
      DbPool pool = new DbPool(config.getConfig("database"), null);
     
    // create database
    BlubSchema schema = new BlubSchema();
    DbManager manager = new DbManager(pool, schema);
   
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.