Package org.apache.empire.db

Examples of org.apache.empire.db.DBRecord


        // Query Records and print output
        printQueryResults(cmd, conn);
       
        // Define an updateable query
        DBQuery Q_EMP_DEP = new DBQuery(cmd, T_EMP.C_EMPLOYEE_ID);
        DBRecord rec = new DBRecord();
        rec.read(Q_EMP_DEP, employeeId, conn);
        // Modify and Update fields from both Employee and Department
        rec.setValue(T_EMP.C_PHONE_NUMBER, "0815-4711");
        rec.setValue(T_DEP.C_BUSINESS_UNIT, "AUTO");
        rec.update(conn);
        // Sucessfully updated
        System.out.println("The employee has been sucessfully updated");
    }   
View Full Code Here


     * </PRE>
   */
  private static int insertDepartment(Connection conn, String departmentName, String businessUnit)
    {
    // Insert a Department
    DBRecord rec = new DBRecord();
    rec.create(db.DEPARTMENTS);
    rec.setValue(db.DEPARTMENTS.NAME, departmentName);
    rec.setValue(db.DEPARTMENTS.BUSINESS_UNIT, businessUnit);
    rec.update(conn);
    // Return Department ID
    return rec.getInt(db.DEPARTMENTS.DEPARTMENT_ID);
  }
View Full Code Here

     * </PRE>
   */
  private static int insertEmployee(Connection conn, String firstName, String lastName, String gender, int departmentId)
    {
    // Insert an Employee
    DBRecord rec = new DBRecord();
    rec.create(db.EMPLOYEES);
    rec.setValue(db.EMPLOYEES.FIRSTNAME, firstName);
    rec.setValue(db.EMPLOYEES.LASTNAME, lastName);
    rec.setValue(db.EMPLOYEES.GENDER, gender);
    rec.setValue(db.EMPLOYEES.DEPARTMENT_ID, departmentId);
    rec.update(conn);
    // Return Employee ID
    return rec.getInt(db.EMPLOYEES.EMPLOYEE_ID);
  }
View Full Code Here

     * </PRE>
   */
  private static void updateEmployee(Connection conn, int idPers, String phoneNumber)
    {
    // Update an Employee
    DBRecord rec = new DBRecord();
    rec.read(db.EMPLOYEES, idPers, conn);
    // Set
    rec.setValue(db.EMPLOYEES.PHONE_NUMBER, phoneNumber);
    rec.update(conn);
  }
View Full Code Here

   
    // STEP 5: Clear Database (Delete all records)
    System.out.println("*** Step 5: clearDatabase() ***");
    clearDatabase(conn, db);

    DBRecord dep = new DBRecord();
    dep.create(db.DEPARTMENT);
    dep.setValue(db.DEPARTMENT.NAME, "junit");
    dep.setValue(db.DEPARTMENT.BUSINESS_UNIT, "中文");
    dep.update(conn);

    int id = dep.getInt(db.DEPARTMENT.ID);

    // Update an Employee
    DBRecord depRead = new DBRecord();
    depRead.read(db.DEPARTMENT, id, conn);

    // You may see ?? in the DB record
    assertEquals("中文", depRead.getString(db.DEPARTMENT.BUSINESS_UNIT));
  }
View Full Code Here

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

     * Insert a department
     */
    private int insertDepartmentSampleRecord(Connection conn, String department_name, String businessUnit)
    {
        // Insert a Department
        DBRecord rec = new DBRecord();
        rec.create(db.DEPARTMENTS);
        rec.setValue(db.DEPARTMENTS.NAME, department_name);
        rec.setValue(db.DEPARTMENTS.BUSINESS_UNIT, businessUnit);
        rec.update(conn);
        // Return Department ID
        return rec.getInt(db.DEPARTMENTS.DEPARTMENT_ID);
    }
View Full Code Here

     */
    private int insertEmployeeSampleRecord(Connection conn, String salutation, String firstName, String lastName,
                                           String gender, int depID)
    {
        // Insert an Employee
        DBRecord rec = new DBRecord();
        rec.create(db.EMPLOYEES);
        rec.setValue(db.EMPLOYEES.SALUTATION, salutation);
        rec.setValue(db.EMPLOYEES.FIRSTNAME, firstName);
        rec.setValue(db.EMPLOYEES.LASTNAME, lastName);
        rec.setValue(db.EMPLOYEES.GENDER, gender);
        rec.setValue(db.EMPLOYEES.DEPARTMENT_ID, depID);
        rec.update(conn);
        // Return Employee ID
        return rec.getInt(db.EMPLOYEES.EMPLOYEE_ID);
    }
View Full Code Here

        removeFromSession();
    }
   
    public DBRecord detachRecord()
    {
        DBRecord rec = record;
        record = null;
        return rec;
    }
View Full Code Here

     * </PRE>
   */
  private static int insertDepartment(Connection conn, String departmentName, String businessUnit)
    {
    // Insert a Department
    DBRecord rec = new DBRecord();
    rec.create(db.DEPARTMENTS);
    rec.setValue(db.DEPARTMENTS.NAME, departmentName);
    rec.setValue(db.DEPARTMENTS.BUSINESS_UNIT, businessUnit);
    rec.update(conn);
    // Return Department ID
    return rec.getInt(db.DEPARTMENTS.DEPARTMENT_ID);
  }
View Full Code Here

TOP

Related Classes of org.apache.empire.db.DBRecord

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.