Package de.mhus.lib.sql

Examples of de.mhus.lib.sql.Dialect


     
      cdb.setConfig("connection", ccon);
     
      cconfig.setConfig("test", cdb);
      DbPoolBundle pool = new DbPoolBundle(cconfig,null);
      Dialect dialect = pool.getPool("test").getDialect();
     
      NodeConfig cqueries = new NodeConfig();
      cqueries.setProperty("create", "create table test (a_text varchar(100))");
      cqueries.setProperty("select", "select * from test");
      cqueries.setProperty("cleanup", "delete from test");
      cqueries.setProperty("insert", "insert into test (a_text) values ($text,text$)");
      cqueries.setProperty("dropblub", "drop table if exists blub_");

      cqueries.setProperty("create2", "create table test2 ("+
          " a_text "   +dialect.getDbType(Dialect.TYPE.STRING.name(), "100") +
          ",a_date "   +dialect.getDbType(Dialect.TYPE.DATETIME.name(), null) +
          ",a_int "    +dialect.getDbType(Dialect.TYPE.INT.name(), null) +
          ",a_bool "   +dialect.getDbType(Dialect.TYPE.BOOL.name(), null) +
          ",a_blob "   +dialect.getDbType(Dialect.TYPE.BLOB.name(), null) +
          ",a_float "  +dialect.getDbType(Dialect.TYPE.FLOAT.name(), null) +
          ",a_double " +dialect.getDbType(Dialect.TYPE.DOUBLE.name(), null) +
          ",a_long "   +dialect.getDbType(Dialect.TYPE.LONG.name(), null) +
          ")");
      cqueries.setProperty("insert2", "insert into test2 (a_text,a_date,a_int,a_bool,a_blob,a_float,a_double,a_long) values ($text$,$date$,$int$,$bool$,$blob$,$float$,$double$,$long$)");
      cqueries.setProperty("cleanup2", "delete from test2");

      cdb.setConfig("queries", cqueries);
View Full Code Here


      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

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

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.