Package de.mhus.lib.sql

Examples of de.mhus.lib.sql.DbStatement


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


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

          // throw e2;
        }
      }
     
      // create database
      DbStatement sthc = con.getStatement("create2");
      try {
        sthc.executeUpdate(null);
          con.commit();
      } catch (Exception e) {e.printStackTrace();}

      int rows = 0;
     
View Full Code Here

    if (attributes == null)
      map = nameMappingRO;
    else
      map = new FallbackMap<String, Object>(attributes, nameMappingRO, true);
    try {
      DbStatement sth = con.createStatement(query);
      DbResult res = sth.executeQuery(map);
      return new DbCollection<T>(this,con,myCon != null,registryName,clazz,res);
    } catch (Throwable t) {
      throw new MException(con,query,attributes,t);
    } finally {
    // do not close, it's used by the collection
View Full Code Here

  }
 
  private void query(IConfig config, LinkedList<CaoElement> list) throws Exception {
    DbConnection con = ((DbCaoConnection)getConnection()).getPool().getConnection();
    String staName = config.getExtracted("statement");
    DbStatement sta = null;
    if (staName != null) {
      sta = con.getStatement(staName);
    } else {
      sta = con.createStatement(config.getString("sql",null));
    }
   
    String tbl = config.getExtracted("table");
    DbMetadata m = ((DbApplication)getApplication()).getMetadata(tbl);
   
    DbResult res = sta.executeQuery(attributes);
    while (res.next()) {
      list.add(new DbData(this,m,res,config));
    }
    res.close();
    con.close();
View Full Code Here

     
    }
    private DbResult createResult() throws Exception {
      DbResult res = null;
      DbConnection con = ((DbCaoConnection)getConnection()).getPool().getConnection();
      DbStatement sth = con.createStatement(queryString);
      if (sth.execute(  ((DbApplication)getApplication()).getMapping() )) {
        res = sth.getResultSet();
      } else {
        res = new MutableResult();
        ((MutableResult)res).addColumnName("count");
        HashMap<String, Object> row = new HashMap<String, Object>();
        row.put("count", sth.getUpdateCount());
        ((MutableResult)res).add(row);
        ((MutableResult)res).reset();
      }
      return res;
    }
View Full Code Here

TOP

Related Classes of de.mhus.lib.sql.DbStatement

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.