Examples of DbConnection


Examples of com.founder.fix.fixflow.shell.DBConnection

 
  public static void rollBack() throws SQLException{
    if(FixFlowShellProxy.isPoolConn()){
      Map<String,DBConnection> dbconns = (CurrentThread.getThreadDBPool().get());
      for(Entry<String,DBConnection> tmp:dbconns.entrySet()){
        DBConnection td = tmp.getValue();
        if(td!=null){
          td.closeAndRockBack();
        }
      }
      getThreadDBPool().set(null);
    }
  }
View Full Code Here

Examples of com.hp.hpl.jena.db.DBConnection

    // load the the driver class
    Class.forName(M_DBDRIVER_CLASS);

    String dbUrl = "jdbc:mysql://" + hostName + "/" + dbName;
    // create a database connection
    IDBConnection conn = new DBConnection(dbUrl, userName, password, "MySQL");

    // create a model maker with the given connection parameters
    ModelMaker maker = ModelFactory.createModelRDBMaker(conn);

    ModelRDB model = (ModelRDB) maker.openModel(modelName);
View Full Code Here

Examples of com.jengine.orm.db.DBConnection

        for (int i=0; i < 10; i++) {
            threads.add(new Thread() {
                public void run() {
                    try {
                        DBConnection connection = DBFactory.get().getConnection();
                        try {
                            check(Book.cls.get(1).getLibrary().equals(Library.cls.get(1)));
                            Library globe = Library.cls.filter("name = ?", "Globe").one();
                            check( globe.getMemberList().size() == 4 );
                            check( globe.getMembers().list().size() == 4 );
View Full Code Here

Examples of data.DBConnection

            dbConfig = new DBConfig( dbConfigResource );
        } catch( FileNotFoundException e ) {
            // @TODO implement error handling
        }

        this.dbConnection = new DBConnection( dbConfig );
        dbConnection.openConnectionn();

        initDriver( dbConfig );
    }
View Full Code Here

Examples of db.DBConnection

    super.init(config);
    dbHost = getInitParameter("DB-Host");
    dbUser = getInitParameter("DB-User");
    dbPassword = getInitParameter("DB-Password");
    dbName = getInitParameter("DB-Name");
    dbConnection = new DBConnection(dbHost, dbUser, dbPassword, dbName);
  }
View Full Code Here

Examples of de.mhus.lib.sql.DbConnection

      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();
View Full Code Here

Examples of de.mhus.lib.sql.DbConnection

     
    }

    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);
          con.commit();
      } catch (Exception e) {e.printStackTrace();}
     
      DbStatement sth = con.getStatement("select");
      try {
        DbResult res = sth.executeQuery(null);
        res.close();
      } catch (ClassNotFoundException e1) {
        System.out.println("testConnect: sql driver not found - skip test");
        return;
      } catch (SQLException e2) {
        if (e2.getMessage().startsWith("Communications link failure")) {
          System.out.println("testConnect: sql db not found - skip test");
          return;
        } else {
          throw e2;
        }
      }
     
      con.commit();

    }
View Full Code Here

Examples of de.mhus.lib.sql.DbConnection

    }
   
    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");
        return;
      } catch (SQLException e2) {
        if (e2.getMessage().startsWith("Communications link failure")) {
          System.out.println("testConnect: sql db not found - skip test");
          return;
        } else {
          throw e2;
        }
      }
      HashMap<String, Object> attr = new HashMap<String, Object>();
      attr.put("text", "abc'");
      con.getStatement("insert").execute(attr);

      DbStatement sth = con.getStatement("select");
      DbResult res1 = sth.executeQuery(null);
      assertEquals(true,res1.next());
      String res2 = res1.getString("a_text");
      assertEquals(attr.get("text"), res2);
      res1.close();
     
      int res3 = con.getStatement("cleanup").executeUpdate(null);
      assertEquals(1, res3);
     
      con.commit();

    }
View Full Code Here

Examples of de.mhus.lib.sql.DbConnection

    }
   
    @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");
        return;
      } catch (SQLException e2) {
        if (e2.getMessage().startsWith("Communications link failure")) {
          System.out.println("testConnect: sql db not found - skip test");
          return;
        } else {
          // throw e2;
        }
      }
     
      // create database
      DbStatement sthc = con.getStatement("create2");
      try {
        sthc.executeUpdate(null);
          con.commit();
      } catch (Exception e) {e.printStackTrace();}

      int rows = 0;
     
      HashMap<String, Object> attr = new HashMap<String, Object>();
      attr.put("text", "abc'");
      attr.put("int", Integer.MAX_VALUE);
      attr.put("date", new Date());
      attr.put("bool", true);
      attr.put("blob", new ByteArrayInputStream("adsjansdjakdjajkhdkjhajkdhkjahdkjakjdkad".getBytes()));
      attr.put("float", 0x1.fffffeP+126f); // 0x1.fffffeP+127f not possible in MySQL
      attr.put("double", Double.MAX_VALUE);
      attr.put("long", Long.MAX_VALUE);
      con.getStatement("insert2").execute(attr);
      rows++;
     
      attr.put("text", "abc'");
      attr.put("int", Integer.MIN_VALUE);
      attr.put("date", new MDate());
      attr.put("bool", false);
      attr.put("blob", new ByteArrayInputStream("adsjansdjakdjajkhdkjhajkdhkjahdkjakjdkad".getBytes()));
      attr.put("float", Float.MIN_VALUE);
      attr.put("double", Double.MIN_VALUE);
      attr.put("long", Long.MIN_VALUE);
      con.getStatement("insert2").execute(attr);
      rows++;

      attr.put("text", "abc'");
      attr.put("int", Integer.MIN_VALUE);
      attr.put("date", new java.sql.Date(0));
      attr.put("bool", false);
      attr.put("blob", new ByteArrayInputStream("adsjansdjakdjajkhdkjhajkdhkjahdkjakjdkad".getBytes()));
      attr.put("float", Float.MIN_VALUE);
      attr.put("double", Double.MIN_VALUE);
      attr.put("long", Long.MIN_VALUE);
      con.getStatement("insert2").execute(attr);
      rows++;

      attr.put("text", "abc'");
      attr.put("int", Integer.MIN_VALUE);
      attr.put("date", new java.sql.Date(2069,12,31)); // max for mysql
      attr.put("bool", false);
      attr.put("blob", new ByteArrayInputStream("adsjansdjakdjajkhdkjhajkdhkjahdkjakjdkad".getBytes()));
      attr.put("float", Float.MIN_VALUE);
      attr.put("double", Double.MIN_VALUE);
      attr.put("long", Long.MIN_VALUE);
      con.getStatement("insert2").execute(attr);
      rows++;
     
      int res3 = con.getStatement("cleanup2").executeUpdate(null);
      assertEquals(rows, res3);
     
      con.commit();

    }
View Full Code Here

Examples of de.mhus.lib.sql.DbConnection

    }
   
    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("--------------------------------------------------");
      dialect.createStructure(cstr, con, null);

      cdata.setProperty("select", "select * from " + tName + " where t_string='ccc'");
      cdata.setProperty("condition", "not found");
      cexec = cdata.createConfig("execute");
      cexec.setProperty("sql", "insert into " + tName + " (t_string,t_int) values ('ccc',3)");

      System.out.println("--------------------------------------------------");
      dialect.createStructure(cstr, con, null);
      System.out.println("--------------------------------------------------");
      dialect.createStructure(cstr, con, null);
     
      con.commit();
      con.close();
    }
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.