Package org.apache.empire.db

Examples of org.apache.empire.db.CompanyDB$Departments


  public void testBlobDDL() throws SQLException
  {
    Connection conn = dbResource.getConnection();

    DBDatabaseDriver driver = dbResource.newDriver();
    CompanyDB db = new CompanyDB();

    // Encoding issue occurs when prepared statement is disabled
    //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


  public void testBlobWritingReading() throws SQLException
  {
    Connection conn = dbResource.getConnection();

    DBDatabaseDriver driver = dbResource.newDriver();
    CompanyDB db = new CompanyDB();

    // Encoding issue occurs when prepared statement is disabled
    //db.setPreparedStatementsEnabled(true);

    db.open(driver, dbResource.getConnection());
   
    DBRecord emp = new DBRecord();
        emp.create(db.DATA);
        emp.setValue(db.DATA.DATA, new byte[]{1,2,3});
        emp.update(conn);
   
    // read a value
    DBCommand cmd = db.createCommand();
    cmd.select(db.DATA.DATA);
    DBReader reader = new DBReader();
    reader.open(cmd, conn);
    while(reader.moveNext()){
      byte[] value = (byte[]) reader.getValue(db.DATA.DATA);
View Full Code Here

    public void test()
    {
        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

    public void test()
    {
        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

    private DBSetExpr expr;
    private CompanyDB testDB;
   
    @Before
    public void setup(){
        testDB = new CompanyDB();
        testDB.open(new MockDriver(), null);
        expr = new DBSetExpr(testDB.EMPLOYEE.FIRSTNAME, "JUnit");
    }
View Full Code Here

        ErrorObject.setExceptionsEnabled(true);
       
        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

  public void testChineseCharacters()
  {
    Connection conn = dbResource.getConnection();

    DBDatabaseDriver driver = dbResource.newDriver();
    CompanyDB db = new CompanyDB();

    // Encoding issue occur when prepared statement is disabled
    //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);
    }
   
    // STEP 5: Clear Database (Delete all records)
    System.out.println("*** Step 5: clearDatabase() ***");
    clearDatabase(conn, db);
View Full Code Here

        conn = DriverManager.getConnection("jdbc:hsqldb:"
                                           + "target/hsqldb-unit-test/",    // filenames
                                           "sa",                     // username
                                           "");                      // password
        DBDatabaseDriver driver = new DBDatabaseDriverHSql();
        db = new CompanyDB();
        db.open(driver, conn);
        DBSQLScript script = new DBSQLScript();
        db.getCreateDDLScript(db.getDriver(), script);
        script.run(db.getDriver(), conn, false);
       
View Full Code Here

  public void testChineseCharacters()
  {
    Connection conn = dbResource.getConnection();

    DBDatabaseDriver driver = dbResource.newDriver();
    CompanyDB db = new CompanyDB();

    // Encoding issue occur when prepared statement is disabled
    //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);
    }
   
    // STEP 5: Clear Database (Delete all records)
    System.out.println("*** Step 5: clearDatabase() ***");
    clearDatabase(conn, db);
View Full Code Here

  public void testBlobDDL() throws SQLException
  {
    Connection conn = dbResource.getConnection();

    DBDatabaseDriver driver = dbResource.newDriver();
    CompanyDB db = new CompanyDB();

    // Encoding issue occurs when prepared statement is disabled
    //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

TOP

Related Classes of org.apache.empire.db.CompanyDB$Departments

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.