Examples of DBSQLScript


Examples of org.apache.empire.db.DBSQLScript

     * </PRE>
   */
  private static void createDatabase(DBDatabaseDriver driver, Connection conn)
    {
    // create DDL for Database Definition
      DBSQLScript script = new DBSQLScript();
    db.getCreateDDLScript(driver, script);
    // Show DDL Statement
    System.out.println(script.toString());
    // Execute Script
    script.run(driver, conn, false);
    // Commit
    db.commit(conn);
  }
View Full Code Here

Examples of org.apache.empire.db.DBSQLScript

        Connection conn = dbResource.getConnection();
    
        DBDatabaseDriver driver = dbResource.newDriver();
        CompanyDB db = new CompanyDB();
        db.open(driver, dbResource.getConnection());
        DBSQLScript script = new DBSQLScript();
        db.getCreateDDLScript(db.getDriver(), script);
        script.run(db.getDriver(), dbResource.getConnection(), false);
       
        DBRecord dep = new DBRecord();
        dep.create(db.DEPARTMENT);
        dep.setValue(db.DEPARTMENT.NAME, "junit");
        dep.setValue(db.DEPARTMENT.BUSINESS_UNIT, "test");
        dep.update(conn);
       
        Date date = dep.getDateTime(db.DEPARTMENT.UPDATE_TIMESTAMP);
        assertNotNull("Date is null", date);
        assertTrue("No departments", dep.getInt(db.DEPARTMENT.ID) > 0);
       
       
        DBRecord emp = new DBRecord();
        emp.create(db.EMPLOYEE);
        emp.setValue(db.EMPLOYEE.FIRSTNAME, "junit");
        emp.setValue(db.EMPLOYEE.LASTNAME, "test");
        emp.setValue(db.EMPLOYEE.GENDER, "m");
        emp.setValue(db.EMPLOYEE.DEPARTMENT_ID, dep.getInt(db.DEPARTMENT.ID));
        emp.update(conn);
       
        date = emp.getDateTime(db.EMPLOYEE.UPDATE_TIMESTAMP);
        assertNotNull("Date is null", date);
        assertTrue("Employee id O or less", emp.getInt(db.EMPLOYEE.ID) > 0);

        int id = emp.getInt(db.EMPLOYEE.ID);
       
        // Update an Employee
        emp = new DBRecord();
        emp.read(db.EMPLOYEE, id, conn);
        // Set
        emp.setValue(db.EMPLOYEE.PHONE_NUMBER, "123456");
        emp.update(conn);
       
        emp = new DBRecord();
        emp.read(db.EMPLOYEE, id, conn);
       
        assertEquals("123456", emp.getString(db.EMPLOYEE.PHONE_NUMBER));
       
       
        script = new DBSQLScript();
        db.getDriver().getDDLScript(DBCmdType.DROP, db.EMPLOYEE, script);
        db.getDriver().getDDLScript(DBCmdType.DROP, db.DEPARTMENT, script);
        script.run(db.getDriver(), conn, true);
    }
View Full Code Here

Examples of org.apache.empire.db.DBSQLScript

      Connection conn = dbResource.getConnection();
       
        DBDatabaseDriver driver = dbResource.newDriver();
        SeqDB db = new SeqDB();
        db.open(driver, dbResource.getConnection());
        DBSQLScript script = new DBSQLScript();
        db.getCreateDDLScript(db.getDriver(), script);
        script.run(db.getDriver(), dbResource.getConnection(), false);
       
        DBRecord data = new DBRecord();
        data.create(db.DATA);
        data.setValue(db.DATA.VALUE, "test");
        data.update(conn);
       
        final Object id = data.getLong(db.DATA.ID);
       
        DBRecord read = new DBRecord();
        read.read(db.DATA, id, conn);
       
        assertEquals("test", read.getString(db.DATA.VALUE));
       
        script = new DBSQLScript();
        db.getDriver().getDDLScript(DBCmdType.DROP, db.DATA, script);
        script.run(db.getDriver(), conn, true);
    }
View Full Code Here

Examples of org.apache.empire.db.DBSQLScript

    //db.setPreparedStatementsEnabled(true);

    db.open(driver, dbResource.getConnection());

    if(!databaseExists(conn, db)){
      DBSQLScript script = new DBSQLScript();
      db.getCreateDDLScript(db.getDriver(), script);
      System.out.println(script.toString());
      script.run(db.getDriver(), dbResource.getConnection(), false);
    }
   
    conn.close();
  }
View Full Code Here

Examples of org.apache.empire.db.DBSQLScript

        Connection conn = dbResource.getConnection();
    
        DBDatabaseDriver driver = dbResource.newDriver();
        CompanyDB db = new CompanyDB();
        db.open(driver, dbResource.getConnection());
        DBSQLScript script = new DBSQLScript();
        db.getCreateDDLScript(db.getDriver(), script);
        script.run(db.getDriver(), dbResource.getConnection(), false);
       
        DBRecord dep = new DBRecord();
        dep.create(db.DEPARTMENT);
        dep.setValue(db.DEPARTMENT.NAME, "junit");
        dep.setValue(db.DEPARTMENT.BUSINESS_UNIT, "test");
        dep.update(conn);
       
        Date date = dep.getDateTime(db.DEPARTMENT.UPDATE_TIMESTAMP);
        assertNotNull("Date is null", date);
        assertTrue("No departments", dep.getInt(db.DEPARTMENT.ID) > 0);
       
        DBRecord emp = new DBRecord();
        emp.create(db.EMPLOYEE);
        emp.setValue(db.EMPLOYEE.FIRSTNAME, "junit");
        emp.setValue(db.EMPLOYEE.LASTNAME, "test");
        emp.setValue(db.EMPLOYEE.GENDER, "m");
        emp.setValue(db.EMPLOYEE.DEPARTMENT_ID, dep.getInt(db.DEPARTMENT.ID));
        emp.update(conn);
       
        date = emp.getDateTime(db.EMPLOYEE.UPDATE_TIMESTAMP);
        assertNotNull("Date is null", date);
        assertTrue("Employee id O or less", emp.getInt(db.EMPLOYEE.ID) > 0);

        int id = emp.getInt(db.EMPLOYEE.ID);
       
        // Update an Employee
        emp = new DBRecord();
        emp.read(db.EMPLOYEE, id, conn);
        // Set
        emp.setValue(db.EMPLOYEE.PHONE_NUMBER, "123456");
        emp.update(conn);
       
        emp = new DBRecord();
        emp.read(db.EMPLOYEE, id, conn);
       
        assertEquals("123456", emp.getString(db.EMPLOYEE.PHONE_NUMBER));
       
        script = new DBSQLScript();
        db.getDriver().getDDLScript(DBCmdType.DROP, db.EMPLOYEE, script);
        db.getDriver().getDDLScript(DBCmdType.DROP, db.DEPARTMENT, script);
        script.run(db.getDriver(), conn, true);
    }
View Full Code Here

Examples of org.apache.empire.db.DBSQLScript

      Connection conn = dbResource.getConnection();
       
        DBDatabaseDriver driver = dbResource.newDriver();
        SeqDB db = new SeqDB();
        db.open(driver, dbResource.getConnection());
        DBSQLScript script = new DBSQLScript();
        db.getCreateDDLScript(db.getDriver(), script);
        script.run(db.getDriver(), dbResource.getConnection(), false);
       
        DBRecord data = new DBRecord();
        data.create(db.DATA);
        data.setValue(db.DATA.VALUE, "test");
        data.update(conn);
       
        final Object id = data.getLong(db.DATA.ID);
       
        DBRecord read = new DBRecord();
        read.read(db.DATA, id, conn);
       
        assertEquals("test", read.getString(db.DATA.VALUE));
       
        script = new DBSQLScript();
        db.getDriver().getDDLScript(DBCmdType.DROP, db.DATA, script);
        script.run(db.getDriver(), conn, true);
    }
View Full Code Here

Examples of org.apache.empire.db.DBSQLScript

    public void createDatabase() {
        Connection conn = getConnection();

        // create DLL for Database Definition
        DBSQLScript script = new DBSQLScript();
        db.getCreateDDLScript(driver, script);
        // Show DLL Statement
        System.out.println(script.toString());
        // Execute Script
        script.run(driver, conn, false);
    }
View Full Code Here

Examples of org.apache.empire.db.DBSQLScript

     * </PRE>
   */
  private static void createDatabase(DBDatabaseDriver driver, Connection conn)
    {
    // create DDL for Database Definition
      DBSQLScript script = new DBSQLScript();
    db.getCreateDDLScript(driver, script);
    // Show DDL Statement
    System.out.println(script.toString());
    // Execute Script
    script.run(driver, conn, false);
    // Commit
    db.commit(conn);
  }
View Full Code Here

Examples of org.apache.empire.db.DBSQLScript

            System.out.println("--------------------------------------------------------");
            System.out.println("*** ddlSample: shows how to add a column at runtime and update a record with the added column ***");
            if (db.getDriver() instanceof DBDatabaseDriverH2) {
              log.info("As H2 does not support changing a table with a view defined we remove the view");
              System.out.println("*** drop EMPLOYEE_INFO_VIEW ***");
              DBSQLScript script = new DBSQLScript();
              db.getDriver().getDDLScript(DBCmdType.DROP, db.V_EMPLOYEE_INFO, script);
              script.run(db.getDriver(), conn, false);
            }
            ddlSample(conn, idEmp2);
            if (db.getDriver() instanceof DBDatabaseDriverH2) {
              log.info("And put back the view");
              System.out.println("*** create EMPLOYEE_INFO_VIEW ***");
              DBSQLScript script = new DBSQLScript();
              db.getDriver().getDDLScript(DBCmdType.CREATE, db.V_EMPLOYEE_INFO, script);
              script.run(db.getDriver(), conn, false);
            }

            // STEP 13: delete records
            System.out.println("--------------------------------------------------------");
            System.out.println("*** deleteRecordSample: shows how to delete records (with and without cascade) ***");
 
View Full Code Here

Examples of org.apache.empire.db.DBSQLScript

     * </PRE>
     */
    private static void createDatabase(DBDatabaseDriver driver, Connection conn)
    {
        // create DLL for Database Definition
        DBSQLScript script = new DBSQLScript();
        db.getCreateDDLScript(driver, script);
        // Show DLL Statement
        System.out.println(script.toString());
        // Execute Script
        script.run(driver, conn, false);
        // Commit
        db.commit(conn);
    }
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.