Return-Path: Delivered-To: apmail-incubator-empire-db-commits-archive@locus.apache.org Received: (qmail 99871 invoked from network); 6 Aug 2008 09:05:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Aug 2008 09:05:27 -0000 Received: (qmail 32908 invoked by uid 500); 6 Aug 2008 09:05:26 -0000 Delivered-To: apmail-incubator-empire-db-commits-archive@incubator.apache.org Received: (qmail 32899 invoked by uid 500); 6 Aug 2008 09:05:26 -0000 Mailing-List: contact empire-db-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: empire-db-dev@incubator.apache.org Delivered-To: mailing list empire-db-commits@incubator.apache.org Received: (qmail 32888 invoked by uid 99); 6 Aug 2008 09:05:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Aug 2008 02:05:26 -0700 X-ASF-Spam-Status: No, hits=-1998.0 required=10.0 tests=ALL_TRUSTED,URIBL_BLACK X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Aug 2008 09:04:32 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 87A102388882; Wed, 6 Aug 2008 02:04:59 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r683184 - in /incubator/empire-db/trunk/core/DBSample: ./ .settings/ Output/ bin/ src/ src/org/ src/org/apache/ src/org/apache/empire/ src/org/apache/empire/samples/ src/org/apache/empire/samples/db/ Date: Wed, 06 Aug 2008 09:04:58 -0000 To: empire-db-commits@incubator.apache.org From: doebele@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080806090459.87A102388882@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: doebele Date: Wed Aug 6 02:04:56 2008 New Revision: 683184 URL: http://svn.apache.org/viewvc?rev=683184&view=rev Log: (empty) Added: incubator/empire-db/trunk/core/DBSample/.classpath incubator/empire-db/trunk/core/DBSample/.cvsignore incubator/empire-db/trunk/core/DBSample/.project incubator/empire-db/trunk/core/DBSample/.settings/ incubator/empire-db/trunk/core/DBSample/.settings/org.eclipse.jdt.ui.prefs incubator/empire-db/trunk/core/DBSample/.settings/org.eclipse.wst.validation.prefs incubator/empire-db/trunk/core/DBSample/Output/ incubator/empire-db/trunk/core/DBSample/Output/SampleOutput.txt incubator/empire-db/trunk/core/DBSample/Output/Step4-CreateDDL.txt incubator/empire-db/trunk/core/DBSample/Output/Step5-ClearDatabase.txt incubator/empire-db/trunk/core/DBSample/Output/Step6-InsertRecords.txt incubator/empire-db/trunk/core/DBSample/Output/Step7-UpdatePerson.txt incubator/empire-db/trunk/core/DBSample/Output/Step8-QueryAsASCII.txt incubator/empire-db/trunk/core/DBSample/bin/ incubator/empire-db/trunk/core/DBSample/classpath_delivery-version incubator/empire-db/trunk/core/DBSample/config.xml incubator/empire-db/trunk/core/DBSample/readme.txt incubator/empire-db/trunk/core/DBSample/src/ incubator/empire-db/trunk/core/DBSample/src/org/ incubator/empire-db/trunk/core/DBSample/src/org/apache/ incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/ incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/ incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/ incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleApp.java incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleBean.java incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleConfig.java incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleDB.java incubator/empire-db/trunk/core/DBSample/tutorial.pdf (with props) Modified: incubator/empire-db/trunk/core/DBSample/ (props changed) Propchange: incubator/empire-db/trunk/core/DBSample/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Wed Aug 6 02:04:56 2008 @@ -0,0 +1 @@ +hsqldb Added: incubator/empire-db/trunk/core/DBSample/.classpath URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/.classpath?rev=683184&view=auto ============================================================================== --- incubator/empire-db/trunk/core/DBSample/.classpath (added) +++ incubator/empire-db/trunk/core/DBSample/.classpath Wed Aug 6 02:04:56 2008 @@ -0,0 +1,8 @@ + + + + + + + + Added: incubator/empire-db/trunk/core/DBSample/.cvsignore URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/.cvsignore?rev=683184&view=auto ============================================================================== --- incubator/empire-db/trunk/core/DBSample/.cvsignore (added) +++ incubator/empire-db/trunk/core/DBSample/.cvsignore Wed Aug 6 02:04:56 2008 @@ -0,0 +1 @@ +hsqldb Added: incubator/empire-db/trunk/core/DBSample/.project URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/.project?rev=683184&view=auto ============================================================================== --- incubator/empire-db/trunk/core/DBSample/.project (added) +++ incubator/empire-db/trunk/core/DBSample/.project Wed Aug 6 02:04:56 2008 @@ -0,0 +1,17 @@ + + + DBSample + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + Added: incubator/empire-db/trunk/core/DBSample/.settings/org.eclipse.jdt.ui.prefs URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/.settings/org.eclipse.jdt.ui.prefs?rev=683184&view=auto ============================================================================== --- incubator/empire-db/trunk/core/DBSample/.settings/org.eclipse.jdt.ui.prefs (added) +++ incubator/empire-db/trunk/core/DBSample/.settings/org.eclipse.jdt.ui.prefs Wed Aug 6 02:04:56 2008 @@ -0,0 +1,3 @@ +#Wed May 02 16:14:09 CEST 2007 +eclipse.preferences.version=1 +org.eclipse.jdt.ui.text.custom_code_templates= Added: incubator/empire-db/trunk/core/DBSample/.settings/org.eclipse.wst.validation.prefs URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/.settings/org.eclipse.wst.validation.prefs?rev=683184&view=auto ============================================================================== --- incubator/empire-db/trunk/core/DBSample/.settings/org.eclipse.wst.validation.prefs (added) +++ incubator/empire-db/trunk/core/DBSample/.settings/org.eclipse.wst.validation.prefs Wed Aug 6 02:04:56 2008 @@ -0,0 +1,6 @@ +#Tue Nov 20 11:27:45 CET 2007 +DELEGATES_PREFERENCE=delegateValidatorListorg.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator\=org.eclipse.wst.wsdl.validation.internal.eclipse.Validator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator\=org.eclipse.wst.xsd.core.internal.validation.eclipse.Validator; +USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.wst.wsi.ui.internal.WSIMessageValidator;org.eclipse.wst.html.internal.validation.HTMLValidator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;org.eclipse.wst.dtd.core.internal.validation.eclipse.Validator; +USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.wst.wsi.ui.internal.WSIMessageValidator;org.eclipse.wst.html.internal.validation.HTMLValidator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;org.eclipse.wst.dtd.core.internal.validation.eclipse.Validator; +USER_PREFERENCE=overrideGlobalPreferencesfalse +eclipse.preferences.version=1 Added: incubator/empire-db/trunk/core/DBSample/Output/SampleOutput.txt URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/Output/SampleOutput.txt?rev=683184&view=auto ============================================================================== --- incubator/empire-db/trunk/core/DBSample/Output/SampleOutput.txt (added) +++ incubator/empire-db/trunk/core/DBSample/Output/SampleOutput.txt Wed Aug 6 02:04:56 2008 @@ -0,0 +1,200 @@ +log4j:WARN No appenders could be found for logger (org.apache.empire.commons.ErrorType). +log4j:WARN Please initialize the log4j system properly. + +INFO [2008/01/08 07:19]: Logging sucessfully configured. at org.apache.empire.xml.XMLConfiguration.initLogging(XMLConfiguration.java:142) +INFO [2008/01/08 07:19]: reading bean properties from node: properties at org.apache.empire.xml.XMLConfiguration.readProperties(XMLConfiguration.java:165) +INFO [2008/01/08 07:19]: Configuration property 'databaseProvider' set to "sqlserver" at org.apache.empire.xml.XMLConfiguration.setPropertyValue(XMLConfiguration.java:196) +INFO [2008/01/08 07:19]: reading bean properties from node: properties-sqlserver at org.apache.empire.xml.XMLConfiguration.readProperties(XMLConfiguration.java:165) +INFO [2008/01/08 07:19]: Configuration property 'jdbcClass' set to "com.microsoft.sqlserver.jdbc.SQLServerDriver" at org.apache.empire.xml.XMLConfiguration.setPropertyValue(XMLConfiguration.java:196) +INFO [2008/01/08 07:19]: Configuration property 'jdbcURL' set to "jdbc:sqlserver://192.168.0.2:1433" at org.apache.empire.xml.XMLConfiguration.setPropertyValue(XMLConfiguration.java:196) +INFO [2008/01/08 07:19]: Configuration property 'jdbcUser' set to "sa" at org.apache.empire.xml.XMLConfiguration.setPropertyValue(XMLConfiguration.java:196) +INFO [2008/01/08 07:19]: Configuration property 'jdbcPwd' set to "esteam" at org.apache.empire.xml.XMLConfiguration.setPropertyValue(XMLConfiguration.java:196) +INFO [2008/01/08 07:19]: Configuration property 'schemaName' set to "DBSAMPLE" at org.apache.empire.xml.XMLConfiguration.setPropertyValue(XMLConfiguration.java:196) + +Running DB Sample... + +*** Step 1: getJDBCConnection() *** +08.01.2008 07:19:18 org.apache.empire.samples.db.SampleApp getJDBCConnection +INFO: Connecting to Database'jdbc:sqlserver://192.168.0.2:1433' / User=sa +08.01.2008 07:19:18 org.apache.empire.samples.db.SampleApp getJDBCConnection +INFO: Connected successfully +08.01.2008 07:19:18 org.apache.empire.samples.db.SampleApp getJDBCConnection +INFO: AutoCommit is false + +*** Step 2: getDatabaseProvider() *** + +*** Step 3: openDatabase() *** +Checking whether table DEPARTMENTS exists (SQLException will be logged if not - please ignore) ... +DEBUG [2008/01/08 07:19]: executing: SELECT count(*) +FROM DEPARTMENTS t1 at org.apache.empire.db.DBDatabase.querySingleValue(DBDatabase.java:601) +DEBUG [2008/01/08 07:19]: querySingleValue complete in 45 ms -> value=2 at org.apache.empire.db.DBDatabase.querySingleValue(DBDatabase.java:621) + +*** Database already exists. Skipping Step4 *** + +*** Step 5: clearDatabase() *** +INFO [2008/01/08 07:19]: Executing: DELETE FROM EMPLOYEES at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 3 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) +INFO [2008/01/08 07:19]: Executing: DELETE FROM DEPARTMENTS at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 2 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) + +*** Step 6: insertDepartment() & insertEmployee() *** +INFO [2008/01/08 07:19]: Executing: UPDATE Sequences +SET SeqValue=21, SeqTime=getdate() +WHERE SeqName='DEP_ID_SEQUENCE' AND SeqTime='2008-01-07 12:25:40.580' at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) +INFO [2008/01/08 07:19]: Executing: INSERT INTO DEPARTMENTS( DEPARTMENT_ID, NAME, BUSINESS_UNIT, UPDATE_TIMESTAMP) VALUES ( 21, 'Development', 'ITTK', '2008-01-08 07:19:19.014') at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) + +INFO [2008/01/08 07:19]: Executing: UPDATE Sequences +SET SeqValue=22, SeqTime=getdate() +WHERE SeqName='DEP_ID_SEQUENCE' AND SeqTime='2008-01-08 07:19:08.710' at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) +INFO [2008/01/08 07:19]: Executing: INSERT INTO DEPARTMENTS( DEPARTMENT_ID, NAME, BUSINESS_UNIT, UPDATE_TIMESTAMP) VALUES ( 22, 'Sales', 'ITTK', '2008-01-08 07:19:19.059') at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) + +INFO [2008/01/08 07:19]: Executing: UPDATE Sequences +SET SeqValue=31, SeqTime=getdate() +WHERE SeqName='EMPLOYEE_ID_SEQUENCE' AND SeqTime='2008-01-07 12:25:47.267' at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) +INFO [2008/01/08 07:19]: Executing: INSERT INTO EMPLOYEES( EMPLOYEE_ID, FIRSTNAME, LASTNAME, DEPARTMENT_ID, GENDER, RETIRED, UPDATE_TIMESTAMP) VALUES ( 31, 'Peter', 'Sharp', 21, 'M', 0, '2008-01-08 07:19:19.059') at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) + +INFO [2008/01/08 07:19]: Executing: UPDATE Sequences +SET SeqValue=32, SeqTime=getdate() +WHERE SeqName='EMPLOYEE_ID_SEQUENCE' AND SeqTime='2008-01-08 07:19:08.727' at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) +INFO [2008/01/08 07:19]: Executing: INSERT INTO EMPLOYEES( EMPLOYEE_ID, FIRSTNAME, LASTNAME, DEPARTMENT_ID, GENDER, RETIRED, UPDATE_TIMESTAMP) VALUES ( 32, 'Fred', 'Bloggs', 21, 'M', 0, '2008-01-08 07:19:19.074') at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) + +INFO [2008/01/08 07:19]: Executing: UPDATE Sequences +SET SeqValue=33, SeqTime=getdate() +WHERE SeqName='EMPLOYEE_ID_SEQUENCE' AND SeqTime='2008-01-08 07:19:08.727' at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 15ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) +INFO [2008/01/08 07:19]: Executing: INSERT INTO EMPLOYEES( EMPLOYEE_ID, FIRSTNAME, LASTNAME, DEPARTMENT_ID, GENDER, RETIRED, UPDATE_TIMESTAMP) VALUES ( 33, 'Emma', 'White', 22, 'F', 0, '2008-01-08 07:19:19.074') at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) + +*** Step 7: updateEmployee() *** +DEBUG [2008/01/08 07:19]: Executing: SELECT t2.EMPLOYEE_ID, t2.SALUTATION, t2.FIRSTNAME, t2.LASTNAME, t2.DATE_OF_BIRTH, t2.DEPARTMENT_ID, t2.GENDER, t2.PHONE_NUMBER, t2.EMAIL, t2.SALARY, t2.RETIRED, t2.UPDATE_TIMESTAMP +FROM EMPLOYEES t2 +WHERE t2.EMPLOYEE_ID=31 at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:993) +DEBUG [2008/01/08 07:19]: executeQuery successful in 0 ms at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:1003) + +INFO [2008/01/08 07:19]: Executing: UPDATE EMPLOYEES +SET PHONE_NUMBER='+49-7531-457160', UPDATE_TIMESTAMP='2008-01-08 07:19:19.104' +WHERE EMPLOYEE_ID=31 AND UPDATE_TIMESTAMP='2008-01-08 07:19:19.060' at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) +DEBUG [2008/01/08 07:19]: Executing: SELECT t2.EMPLOYEE_ID, t2.SALUTATION, t2.FIRSTNAME, t2.LASTNAME, t2.DATE_OF_BIRTH, t2.DEPARTMENT_ID, t2.GENDER, t2.PHONE_NUMBER, t2.EMAIL, t2.SALARY, t2.RETIRED, t2.UPDATE_TIMESTAMP +FROM EMPLOYEES t2 +WHERE t2.EMPLOYEE_ID=32 at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:993) +DEBUG [2008/01/08 07:19]: executeQuery successful in 0 ms at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:1003) + +INFO [2008/01/08 07:19]: Executing: UPDATE EMPLOYEES +SET PHONE_NUMBER='+49-5555-505050', UPDATE_TIMESTAMP='2008-01-08 07:19:19.104' +WHERE EMPLOYEE_ID=32 AND UPDATE_TIMESTAMP='2008-01-08 07:19:19.073' at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) +DEBUG [2008/01/08 07:19]: Executing: SELECT t2.EMPLOYEE_ID, t2.SALUTATION, t2.FIRSTNAME, t2.LASTNAME, t2.DATE_OF_BIRTH, t2.DEPARTMENT_ID, t2.GENDER, t2.PHONE_NUMBER, t2.EMAIL, t2.SALARY, t2.RETIRED, t2.UPDATE_TIMESTAMP +FROM EMPLOYEES t2 +WHERE t2.EMPLOYEE_ID=33 at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:993) +DEBUG [2008/01/08 07:19]: executeQuery successful in 0 ms at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:1003) + +INFO [2008/01/08 07:19]: Executing: UPDATE EMPLOYEES +SET PHONE_NUMBER='+49-040-125486', UPDATE_TIMESTAMP='2008-01-08 07:19:19.119' +WHERE EMPLOYEE_ID=33 AND UPDATE_TIMESTAMP='2008-01-08 07:19:19.073' at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) + +*** Step 8 Option 1: queryRecords() / Tab-Output *** +Running Query: +SELECT t2.EMPLOYEE_ID, t2.LASTNAME + ', ' + t2.FIRSTNAME AS FULL_NAME, t2.GENDER, t2.PHONE_NUMBER, t1.NAME AS DEPARTMENT, t1.BUSINESS_UNIT +FROM EMPLOYEES t2 INNER JOIN DEPARTMENTS t1 ON t1.DEPARTMENT_ID = t2.DEPARTMENT_ID +WHERE len(t2.LASTNAME)>0 +ORDER BY t2.LASTNAME + +DEBUG [2008/01/08 07:19]: Executing: SELECT t2.EMPLOYEE_ID, t2.LASTNAME + ', ' + t2.FIRSTNAME AS FULL_NAME, t2.GENDER, t2.PHONE_NUMBER, t1.NAME AS DEPARTMENT, t1.BUSINESS_UNIT + +FROM EMPLOYEES t2 INNER JOIN DEPARTMENTS t1 ON t1.DEPARTMENT_ID = t2.DEPARTMENT_ID +WHERE len(t2.LASTNAME)>0 +ORDER BY t2.LASTNAME at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:993) + +DEBUG [2008/01/08 07:19]: executeQuery successful in 0 ms at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:1003) + +--------------------------------- +32 Bloggs, Fred Male Development +31 Sharp, Peter Male Development +33 White, Emma Female Sales + +*** Step 8 Option 2: queryRecords() / Bean-List-Output *** +Running Query: +SELECT t2.EMPLOYEE_ID, t2.LASTNAME + ', ' + t2.FIRSTNAME AS FULL_NAME, t2.GENDER, t2.PHONE_NUMBER, t1.NAME AS DEPARTMENT, t1.BUSINESS_UNIT +FROM EMPLOYEES t2 INNER JOIN DEPARTMENTS t1 ON t1.DEPARTMENT_ID = t2.DEPARTMENT_ID +WHERE len(t2.LASTNAME)>0 +ORDER BY t2.LASTNAME + +DEBUG [2008/01/08 07:19]: Executing: SELECT t2.EMPLOYEE_ID, t2.LASTNAME + ', ' + t2.FIRSTNAME AS FULL_NAME, t2.GENDER, t2.PHONE_NUMBER, t1.NAME AS DEPARTMENT, t1.BUSINESS_UNIT + +FROM EMPLOYEES t2 INNER JOIN DEPARTMENTS t1 ON t1.DEPARTMENT_ID = t2.DEPARTMENT_ID +WHERE len(t2.LASTNAME)>0 +ORDER BY t2.LASTNAME at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:993) + +DEBUG [2008/01/08 07:19]: executeQuery successful in 0 ms at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:1003) + +--------------------------------- +3 SampleBeans returned from Query. +32 Bloggs, Fred M Development ITTK +31 Sharp, Peter M Development ITTK +33 White, Emma F Sales ITTK + +*** Step 8 Option 3: queryRecords() / XML-Output *** +Running Query: +SELECT t2.EMPLOYEE_ID, t2.LASTNAME + ', ' + t2.FIRSTNAME AS FULL_NAME, t2.GENDER, t2.PHONE_NUMBER, t1.NAME AS DEPARTMENT, t1.BUSINESS_UNIT +FROM EMPLOYEES t2 INNER JOIN DEPARTMENTS t1 ON t1.DEPARTMENT_ID = t2.DEPARTMENT_ID +WHERE len(t2.LASTNAME)>0 +ORDER BY t2.LASTNAME + +DEBUG [2008/01/08 07:19]: Executing: SELECT t2.EMPLOYEE_ID, t2.LASTNAME + ', ' + t2.FIRSTNAME AS FULL_NAME, t2.GENDER, t2.PHONE_NUMBER, t1.NAME AS DEPARTMENT, t1.BUSINESS_UNIT + +FROM EMPLOYEES t2 INNER JOIN DEPARTMENTS t1 ON t1.DEPARTMENT_ID = t2.DEPARTMENT_ID +WHERE len(t2.LASTNAME)>0 +ORDER BY t2.LASTNAME at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:993) + +DEBUG [2008/01/08 07:19]: executeQuery successful in 15 ms at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:1003) + +--------------------------------- + + + + + + + + + + + + + + 32 + Bloggs, Fred + M + +49-5555-505050 + Development + ITTK + + + 31 + Sharp, Peter + M + +49-7531-457160 + Development + ITTK + + + 33 + White, Emma + F + +49-040-125486 + Sales + ITTK + + + +DB Sample finished successfully. \ No newline at end of file Added: incubator/empire-db/trunk/core/DBSample/Output/Step4-CreateDDL.txt URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/Output/Step4-CreateDDL.txt?rev=683184&view=auto ============================================================================== --- incubator/empire-db/trunk/core/DBSample/Output/Step4-CreateDDL.txt (added) +++ incubator/empire-db/trunk/core/DBSample/Output/Step4-CreateDDL.txt Wed Aug 6 02:04:56 2008 @@ -0,0 +1,40 @@ +*** Step 4: createDDL() *** + +-- creating sequence for column DEPARTMENTS.DEPARTMENT_ID -- +CREATE SEQUENCE DEP_ID_SEQUENCE START WITH 1; + +-- creating sequence for column EMPLOYEES.EMPLOYEE_ID -- +CREATE SEQUENCE EMPLOYEE_ID_SEQUENCE START WITH 1; + +-- creating table DEPARTMENTS -- +CREATE TABLE DEPARTMENTS ( + DEPARTMENT_ID INTEGER NOT NULL, + NAME VARCHAR(80) NOT NULL, + HEAD VARCHAR(80), + BUSINESS_UNIT VARCHAR(4) NOT NULL, + UPDATE_TIMESTAMP DATE NOT NULL, + CONSTRAINT DEPARTMENTS_PK PRIMARY KEY (DEPARTMENT_ID)); + +CREATE UNIQUE INDEX DEARTMENT_NAME_IDX ON DEPARTMENTS (NAME); + +-- creating table EMPLOYEES -- +CREATE TABLE EMPLOYEES ( + EMPLOYEE_ID INTEGER NOT NULL, + SALUTATION VARCHAR(20), + FIRSTNAME VARCHAR(40) NOT NULL, + LASTNAME VARCHAR(40) NOT NULL, + DATE_OF_BIRTH DATE, + DEPARTMENT_ID INTEGER NOT NULL, + GENDER VARCHAR(1), + PHONE_NUMBER VARCHAR(40), + EMAIL VARCHAR(80), + SALARY DECIMAL(10,2), + RETIRED BOOLEAN NOT NULL, + UPDATE_TIMESTAMP DATE NOT NULL, + CONSTRAINT EMPLOYEES_PK PRIMARY KEY (EMPLOYEE_ID)); + +CREATE UNIQUE INDEX EMPLOYEE_NAME_IDX ON EMPLOYEES (FIRSTNAME, LASTNAME, DATE_OF_BIRTH); + +-- creating foreign key constraint EMPLOYEES_DEPARTMENT_I_FK -- +ALTER TABLE EMPLOYEES ADD CONSTRAINT EMPLOYEES_DEPARTMENT_I_FK FOREIGN KEY (DEPARTMENT_ID) REFERENCES DEPARTMENTS (DEPARTMENT_ID); + Added: incubator/empire-db/trunk/core/DBSample/Output/Step5-ClearDatabase.txt URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/Output/Step5-ClearDatabase.txt?rev=683184&view=auto ============================================================================== --- incubator/empire-db/trunk/core/DBSample/Output/Step5-ClearDatabase.txt (added) +++ incubator/empire-db/trunk/core/DBSample/Output/Step5-ClearDatabase.txt Wed Aug 6 02:04:56 2008 @@ -0,0 +1,6 @@ +*** Step 5: clearDatabase() *** + +INFO [2008/01/08 07:19]: Executing: DELETE FROM EMPLOYEES at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 3 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) +INFO [2008/01/08 07:19]: Executing: DELETE FROM DEPARTMENTS at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 2 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) \ No newline at end of file Added: incubator/empire-db/trunk/core/DBSample/Output/Step6-InsertRecords.txt URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/Output/Step6-InsertRecords.txt?rev=683184&view=auto ============================================================================== --- incubator/empire-db/trunk/core/DBSample/Output/Step6-InsertRecords.txt (added) +++ incubator/empire-db/trunk/core/DBSample/Output/Step6-InsertRecords.txt Wed Aug 6 02:04:56 2008 @@ -0,0 +1,41 @@ +*** Step 6: insertDepartment() & insertEmployee() *** + +INFO [2008/01/08 07:19]: Executing: UPDATE Sequences +SET SeqValue=21, SeqTime=getdate() +WHERE SeqName='DEP_ID_SEQUENCE' AND SeqTime='2008-01-07 12:25:40.580' at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) + +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) +INFO [2008/01/08 07:19]: Executing: INSERT INTO DEPARTMENTS( DEPARTMENT_ID, NAME, BUSINESS_UNIT, UPDATE_TIMESTAMP) VALUES ( 21, 'Development', 'ITTK', '2008-01-08 07:19:19.014') at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) + +INFO [2008/01/08 07:19]: Executing: UPDATE Sequences +SET SeqValue=22, SeqTime=getdate() +WHERE SeqName='DEP_ID_SEQUENCE' AND SeqTime='2008-01-08 07:19:08.710' at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) + +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) +INFO [2008/01/08 07:19]: Executing: INSERT INTO DEPARTMENTS( DEPARTMENT_ID, NAME, BUSINESS_UNIT, UPDATE_TIMESTAMP) VALUES ( 22, 'Sales', 'ITTK', '2008-01-08 07:19:19.059') at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) + +INFO [2008/01/08 07:19]: Executing: UPDATE Sequences +SET SeqValue=31, SeqTime=getdate() +WHERE SeqName='EMPLOYEE_ID_SEQUENCE' AND SeqTime='2008-01-07 12:25:47.267' at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) + +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) +INFO [2008/01/08 07:19]: Executing: INSERT INTO EMPLOYEES( EMPLOYEE_ID, FIRSTNAME, LASTNAME, DEPARTMENT_ID, GENDER, RETIRED, UPDATE_TIMESTAMP) VALUES ( 31, 'Peter', 'Sharp', 21, 'M', 0, '2008-01-08 07:19:19.059') at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) + +INFO [2008/01/08 07:19]: Executing: UPDATE Sequences +SET SeqValue=32, SeqTime=getdate() +WHERE SeqName='EMPLOYEE_ID_SEQUENCE' AND SeqTime='2008-01-08 07:19:08.727' at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) + +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) +INFO [2008/01/08 07:19]: Executing: INSERT INTO EMPLOYEES( EMPLOYEE_ID, FIRSTNAME, LASTNAME, DEPARTMENT_ID, GENDER, RETIRED, UPDATE_TIMESTAMP) VALUES ( 32, 'Fred', 'Bloggs', 21, 'M', 0, '2008-01-08 07:19:19.074') at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) + +INFO [2008/01/08 07:19]: Executing: UPDATE Sequences +SET SeqValue=33, SeqTime=getdate() +WHERE SeqName='EMPLOYEE_ID_SEQUENCE' AND SeqTime='2008-01-08 07:19:08.727' at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) + +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 15ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) +INFO [2008/01/08 07:19]: Executing: INSERT INTO EMPLOYEES( EMPLOYEE_ID, FIRSTNAME, LASTNAME, DEPARTMENT_ID, GENDER, RETIRED, UPDATE_TIMESTAMP) VALUES ( 33, 'Emma', 'White', 22, 'F', 0, '2008-01-08 07:19:19.074') at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) Added: incubator/empire-db/trunk/core/DBSample/Output/Step7-UpdatePerson.txt URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/Output/Step7-UpdatePerson.txt?rev=683184&view=auto ============================================================================== --- incubator/empire-db/trunk/core/DBSample/Output/Step7-UpdatePerson.txt (added) +++ incubator/empire-db/trunk/core/DBSample/Output/Step7-UpdatePerson.txt Wed Aug 6 02:04:56 2008 @@ -0,0 +1,29 @@ +*** Step 7: updateEmployee() *** + +DEBUG [2008/01/08 07:19]: Executing: SELECT t2.EMPLOYEE_ID, t2.SALUTATION, t2.FIRSTNAME, t2.LASTNAME, t2.DATE_OF_BIRTH, t2.DEPARTMENT_ID, t2.GENDER, t2.PHONE_NUMBER, t2.EMAIL, t2.SALARY, t2.RETIRED, t2.UPDATE_TIMESTAMP +FROM EMPLOYEES t2 +WHERE t2.EMPLOYEE_ID=31 at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:993) +DEBUG [2008/01/08 07:19]: executeQuery successful in 0 ms at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:1003) + +INFO [2008/01/08 07:19]: Executing: UPDATE EMPLOYEES +SET PHONE_NUMBER='+49-7531-457160', UPDATE_TIMESTAMP='2008-01-08 07:19:19.104' +WHERE EMPLOYEE_ID=31 AND UPDATE_TIMESTAMP='2008-01-08 07:19:19.060' at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) +DEBUG [2008/01/08 07:19]: Executing: SELECT t2.EMPLOYEE_ID, t2.SALUTATION, t2.FIRSTNAME, t2.LASTNAME, t2.DATE_OF_BIRTH, t2.DEPARTMENT_ID, t2.GENDER, t2.PHONE_NUMBER, t2.EMAIL, t2.SALARY, t2.RETIRED, t2.UPDATE_TIMESTAMP +FROM EMPLOYEES t2 +WHERE t2.EMPLOYEE_ID=32 at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:993) +DEBUG [2008/01/08 07:19]: executeQuery successful in 0 ms at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:1003) + +INFO [2008/01/08 07:19]: Executing: UPDATE EMPLOYEES +SET PHONE_NUMBER='+49-5555-505050', UPDATE_TIMESTAMP='2008-01-08 07:19:19.104' +WHERE EMPLOYEE_ID=32 AND UPDATE_TIMESTAMP='2008-01-08 07:19:19.073' at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) +DEBUG [2008/01/08 07:19]: Executing: SELECT t2.EMPLOYEE_ID, t2.SALUTATION, t2.FIRSTNAME, t2.LASTNAME, t2.DATE_OF_BIRTH, t2.DEPARTMENT_ID, t2.GENDER, t2.PHONE_NUMBER, t2.EMAIL, t2.SALARY, t2.RETIRED, t2.UPDATE_TIMESTAMP +FROM EMPLOYEES t2 +WHERE t2.EMPLOYEE_ID=33 at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:993) +DEBUG [2008/01/08 07:19]: executeQuery successful in 0 ms at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:1003) + +INFO [2008/01/08 07:19]: Executing: UPDATE EMPLOYEES +SET PHONE_NUMBER='+49-040-125486', UPDATE_TIMESTAMP='2008-01-08 07:19:19.119' +WHERE EMPLOYEE_ID=33 AND UPDATE_TIMESTAMP='2008-01-08 07:19:19.073' at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:938) +INFO [2008/01/08 07:19]: executeSQL affected 1 Records / 0ms at org.apache.empire.db.DBDatabase.executeSQL(DBDatabase.java:944) Added: incubator/empire-db/trunk/core/DBSample/Output/Step8-QueryAsASCII.txt URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/Output/Step8-QueryAsASCII.txt?rev=683184&view=auto ============================================================================== --- incubator/empire-db/trunk/core/DBSample/Output/Step8-QueryAsASCII.txt (added) +++ incubator/empire-db/trunk/core/DBSample/Output/Step8-QueryAsASCII.txt Wed Aug 6 02:04:56 2008 @@ -0,0 +1,101 @@ +*** Step 8 Option 1: queryRecords() / Tab-Output *** + +Running Query: +SELECT t2.EMPLOYEE_ID, t2.LASTNAME + ', ' + t2.FIRSTNAME AS FULL_NAME, t2.GENDER, t2.PHONE_NUMBER, t1.NAME AS DEPARTMENT, t1.BUSINESS_UNIT +FROM EMPLOYEES t2 INNER JOIN DEPARTMENTS t1 ON t1.DEPARTMENT_ID = t2.DEPARTMENT_ID +WHERE len(t2.LASTNAME)>0 +ORDER BY t2.LASTNAME + +DEBUG [2008/01/08 07:19]: Executing: SELECT t2.EMPLOYEE_ID, t2.LASTNAME + ', ' + t2.FIRSTNAME AS FULL_NAME, t2.GENDER, t2.PHONE_NUMBER, t1.NAME AS DEPARTMENT, t1.BUSINESS_UNIT + +FROM EMPLOYEES t2 INNER JOIN DEPARTMENTS t1 ON t1.DEPARTMENT_ID = t2.DEPARTMENT_ID +WHERE len(t2.LASTNAME)>0 +ORDER BY t2.LASTNAME at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:993) + +DEBUG [2008/01/08 07:19]: executeQuery successful in 0 ms at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:1003) + +--------------------------------- +32 Bloggs, Fred Male Development +31 Sharp, Peter Male Development +33 White, Emma Female Sales + + +*** Step 8 Option 2: queryRecords() / Bean-List-Output *** + +Running Query: +SELECT t2.EMPLOYEE_ID, t2.LASTNAME + ', ' + t2.FIRSTNAME AS FULL_NAME, t2.GENDER, t2.PHONE_NUMBER, t1.NAME AS DEPARTMENT, t1.BUSINESS_UNIT +FROM EMPLOYEES t2 INNER JOIN DEPARTMENTS t1 ON t1.DEPARTMENT_ID = t2.DEPARTMENT_ID +WHERE len(t2.LASTNAME)>0 +ORDER BY t2.LASTNAME + +DEBUG [2008/01/08 07:19]: Executing: SELECT t2.EMPLOYEE_ID, t2.LASTNAME + ', ' + t2.FIRSTNAME AS FULL_NAME, t2.GENDER, t2.PHONE_NUMBER, t1.NAME AS DEPARTMENT, t1.BUSINESS_UNIT + +FROM EMPLOYEES t2 INNER JOIN DEPARTMENTS t1 ON t1.DEPARTMENT_ID = t2.DEPARTMENT_ID +WHERE len(t2.LASTNAME)>0 +ORDER BY t2.LASTNAME at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:993) + +DEBUG [2008/01/08 07:19]: executeQuery successful in 0 ms at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:1003) + +--------------------------------- +3 SampleBeans returned from Query. +32 Bloggs, Fred M Development ITTK +31 Sharp, Peter M Development ITTK +33 White, Emma F Sales ITTK + + +*** Step 8 Option 3: queryRecords() / XML-Output *** + +Running Query: +SELECT t2.EMPLOYEE_ID, t2.LASTNAME + ', ' + t2.FIRSTNAME AS FULL_NAME, t2.GENDER, t2.PHONE_NUMBER, t1.NAME AS DEPARTMENT, t1.BUSINESS_UNIT +FROM EMPLOYEES t2 INNER JOIN DEPARTMENTS t1 ON t1.DEPARTMENT_ID = t2.DEPARTMENT_ID +WHERE len(t2.LASTNAME)>0 +ORDER BY t2.LASTNAME + +DEBUG [2008/01/08 07:19]: Executing: SELECT t2.EMPLOYEE_ID, t2.LASTNAME + ', ' + t2.FIRSTNAME AS FULL_NAME, t2.GENDER, t2.PHONE_NUMBER, t1.NAME AS DEPARTMENT, t1.BUSINESS_UNIT + +FROM EMPLOYEES t2 INNER JOIN DEPARTMENTS t1 ON t1.DEPARTMENT_ID = t2.DEPARTMENT_ID +WHERE len(t2.LASTNAME)>0 +ORDER BY t2.LASTNAME at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:993) + +DEBUG [2008/01/08 07:19]: executeQuery successful in 15 ms at org.apache.empire.db.DBDatabase.executeQuery(DBDatabase.java:1003) + +--------------------------------- + + + + + + + + + + + + + + 32 + Bloggs, Fred + M + +49-5555-505050 + Development + ITTK + + + 31 + Sharp, Peter + M + +49-7531-457160 + Development + ITTK + + + 33 + White, Emma + F + +49-040-125486 + Sales + ITTK + + + +DB Sample finished successfully. \ No newline at end of file Added: incubator/empire-db/trunk/core/DBSample/classpath_delivery-version URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/classpath_delivery-version?rev=683184&view=auto ============================================================================== --- incubator/empire-db/trunk/core/DBSample/classpath_delivery-version (added) +++ incubator/empire-db/trunk/core/DBSample/classpath_delivery-version Wed Aug 6 02:04:56 2008 @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file Added: incubator/empire-db/trunk/core/DBSample/config.xml URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/config.xml?rev=683184&view=auto ============================================================================== --- incubator/empire-db/trunk/core/DBSample/config.xml (added) +++ incubator/empire-db/trunk/core/DBSample/config.xml Wed Aug 6 02:04:56 2008 @@ -0,0 +1,94 @@ + + + + + + hsqldb + + + + + + org.hsqldb.jdbcDriver + jdbc:hsqldb:file:hsqldb/sample;shutdown=true + sa + + DBSAMPLE + + + + + + com.mysql.jdbc.Driver + jdbc:mysql://localhost + root + esteam + DBSAMPLE + + + + + + oracle.jdbc.driver.OracleDriver + jdbc:oracle:thin:@192.168.0.2:1521:ora10 + DBSAMPLE + DBSAMPLE + DBSAMPLE + + + + + + com.microsoft.sqlserver.jdbc.SQLServerDriver + jdbc:sqlserver://192.168.0.2:1433 + sa + esteam + DBSAMPLE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: incubator/empire-db/trunk/core/DBSample/readme.txt URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/readme.txt?rev=683184&view=auto ============================================================================== --- incubator/empire-db/trunk/core/DBSample/readme.txt (added) +++ incubator/empire-db/trunk/core/DBSample/readme.txt Wed Aug 6 02:04:56 2008 @@ -0,0 +1,10 @@ +In order to run / debug the Empire-db SampleApp please do the following: + +1. In Eclipse IDE use File -> Import -> Existing Projects into Workspace to import the Sample Project + +2. Open the file org.apache.empire.samples.db.SampleApp.java in the src folder and set a breakpoint in first code line of the main() function. + +3. Then right-click on the DBSample Project Node and select Debug-As -> 3 Java Application and select the "SampleApp" class + +The Sample uses a HSQLDB database. If you want to use another database system you will have to add the driver jar file to the the classpath +and change the config.xml file accordingly. Added: incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleApp.java URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleApp.java?rev=683184&view=auto ============================================================================== --- incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleApp.java (added) +++ incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleApp.java Wed Aug 6 02:04:56 2008 @@ -0,0 +1,406 @@ +package org.apache.empire.samples.db; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.util.List; +import java.util.logging.Logger; + +import org.apache.empire.commons.ErrorObject; +import org.apache.empire.db.DBColumnExpr; +import org.apache.empire.db.DBCommand; +import org.apache.empire.db.DBDatabaseDriver; +import org.apache.empire.db.DBReader; +import org.apache.empire.db.DBRecord; +import org.apache.empire.db.DBSQLScript; +import org.apache.empire.db.hsql.DBDatabaseDriverHSql; +import org.apache.empire.db.mysql.DBDatabaseDriverMySQL; +import org.apache.empire.db.oracle.DBDatabaseDriverOracle; +import org.apache.empire.db.sqlserver.DBDatabaseDriverMSSQL; +import org.apache.empire.xml.XMLWriter; +import org.w3c.dom.Document; + + +public class SampleApp +{ + public static Logger logger = Logger.getLogger(SampleApp.class.getName()); + + private static final SampleDB db = new SampleDB(); + + private static SampleConfig config = new SampleConfig(); + + private enum QueryType + { + Reader, + BeanList, + XmlDocument + } + + /** + *
+	 * This is the entry point of the Empire-DB Sample Application
+	 * Please check the config.xml configuration file for Database and Connection settings.
+     * 
+ */ + public static void main(String[] args) + { + try + { + // Init Configuration + config.init((args.length > 0 ? args[0] : "config.xml" )); + + // Enable Exceptions + ErrorObject.setExceptionsEnabled(true); + + System.out.println("Running DB Sample..."); + + // STEP 1: Get a JDBC Connection + System.out.println("*** Step 1: getJDBCConnection() ***"); + Connection conn = getJDBCConnection(); + + // STEP 2: Choose a driver + System.out.println("*** Step 2: getDatabaseProvider() ***"); + DBDatabaseDriver driver = getDatabaseDriver(config.getDatabaseProvider()); + + // STEP 3: Open Database (and create if not existing) + System.out.println("*** Step 3: openDatabase() ***"); + try { + db.open(driver, conn); + databaseExists(conn); + System.out.println("*** Database already exists. Skipping Step4 ***"); + + } catch(Exception e) { + // STEP 4: Create Database + System.out.println("*** Step 4: createDDL() ***"); + createDatabase(driver, conn); + // Open again + if (db.isOpen()==false) + db.open(driver, conn); + } + + // STEP 5: Clear Database (Delete all records) + System.out.println("*** Step 5: clearDatabase() ***"); + clearDatabase(conn); + + // STEP 6: Insert Departments + System.out.println("*** Step 6: insertDepartment() & insertEmployee() ***"); + int idDevDep = insertDepartment(conn, "Development", "ITTK"); + int idSalDep = insertDepartment(conn, "Sales", "ITTK"); + // Insert Employees + int idPers1 = insertEmployee(conn, "Peter", "Sharp", "M", idDevDep); + int idPers2 = insertEmployee(conn, "Fred", "Bloggs", "M", idDevDep); + int idPers3 = insertEmployee(conn, "Emma", "White", "F", idSalDep); + + // STEP 7: Update Records (by setting the phone Number) + System.out.println("*** Step 7: updateEmployee() ***"); + updateEmployee(conn, idPers1, "+49-7531-457160"); + updateEmployee(conn, idPers2, "+49-5555-505050"); + updateEmployee(conn, idPers3, "+49-040-125486"); + + // commit + db.commit(conn); + + // STEP 8: Option 1: Query Records and print tab-separated + System.out.println("*** Step 8 Option 1: queryRecords() / Tab-Output ***"); + queryRecords(conn, QueryType.Reader); // Tab-Output + + // STEP 8: Option 2: Query Records as a list of java beans + System.out.println("*** Step 8 Option 2: queryRecords() / Bean-List-Output ***"); + queryRecords(conn, QueryType.BeanList); // Bean-List-Output + + // STEP 8: Option 3: Query Records as XML + System.out.println("*** Step 8 Option 3: queryRecords() / XML-Output ***"); + queryRecords(conn, QueryType.XmlDocument); // XML-Output + + // Done + System.out.println("DB Sample finished successfully."); + + } catch (Exception e) + { + // Error + System.out.println(e.toString()); + e.printStackTrace(); + } + + } + + /** + *
+	 * Opens and returns a JDBC-Connection.
+	 * JDBC url, user and password for the connection are obained from the SampleConfig bean
+	 * Please use the config.xml file to change connection params.
+     * 
+ */ + private static Connection getJDBCConnection() + { + // Establish a new database connection + Connection conn = null; + logger.info("Connecting to Database'" + config.getJdbcURL() + "' / User=" + config.getJdbcUser()); + try + { + // Connect to the databse + Class.forName(config.getJdbcClass()).newInstance(); + conn = DriverManager.getConnection(config.getJdbcURL(), config.getJdbcUser(), config.getJdbcPwd()); + logger.info("Connected successfully"); + // set the AutoCommit to false this session. You must commit + // explicitly now + conn.setAutoCommit(false); + logger.info("AutoCommit is " + conn.getAutoCommit()); + + } catch (Exception e) + { + logger.severe("Failed to connect directly to '" + config.getJdbcURL() + "' / User=" + config.getJdbcUser()); + logger.severe(e.toString()); + throw new RuntimeException(e); + } + return conn; + } + + /** + *
+     * Returns the correspondig DatabaseDriver for a given database provider / vendor
+     * Valid Providers are "oracle", "sqlserver" and "hsqldb".
+     * 
+ */ + private static DBDatabaseDriver getDatabaseDriver(String provider) + { + if (provider.equalsIgnoreCase("mysql")) + { + DBDatabaseDriverMySQL driver = new DBDatabaseDriverMySQL(); + // Set Driver specific properties (if any) + driver.setDatabaseName(config.getSchemaName()); + return driver; + } + else if (provider.equalsIgnoreCase("oracle")) + { + DBDatabaseDriverOracle driver = new DBDatabaseDriverOracle(); + // Set Driver specific properties (if any) + return driver; + } + else if (provider.equalsIgnoreCase("sqlserver")) + { + DBDatabaseDriverMSSQL driver = new DBDatabaseDriverMSSQL(); + // Set Driver specific properties (if any) + driver.setDatabaseName(config.getSchemaName()); + return driver; + } + else if (provider.equalsIgnoreCase("hsqldb")) + { + DBDatabaseDriverHSql driver = new DBDatabaseDriverHSql(); + // Set Driver specific properties (if any) + return driver; + } + else + { // Unknown Provider + throw new RuntimeException("Unknown Database Provider " + provider); + } + } + + /** + *
+	 * Checks whether the database exists or not by executing
+	 *     select count(*) from DEPARTMENTS
+	 * If the Departments table does not exist the querySingleInt() function return -1 for failure.
+	 * Please note that in this case an error will appear in the log wich can be ingored.
+     * 
+ */ + private static boolean databaseExists(Connection conn) + { + // Check wether DB exists + DBCommand cmd = db.createCommand(); + cmd.select(db.DEPARTMENTS.count()); + // Check using "select count(*) from DEPARTMENTS" + System.out.println("Checking whether table DEPARTMENTS exists (SQLException will be logged if not - please ignore) ..."); + return (db.querySingleInt(cmd.getSelect(), -1, conn) >= 0); + } + + /** + *
+	 * Creates a DDL Script for entire SampleDB Database and executes it line by line.
+	 * Please make sure you uses the correct DatabaseDriver for your target dbms.
+     * 
+ */ + 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); + } + + /** + *
+	 * Empties all Tables.
+     * 
+ */ + private static void clearDatabase(Connection conn) + { + DBCommand cmd = db.createCommand(); + // Delete all Employees (no constraints) + db.executeSQL(cmd.getDelete(db.EMPLOYEES), conn); + // Delete all Departments (no constraints) + db.executeSQL(cmd.getDelete(db.DEPARTMENTS), conn); + } + + /** + *
+	 * Insert a Department into the Departments table.
+     * 
+ */ + 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); + } + + /** + *
+	 * Inserts an Employee into the Employees table.
+     * 
+ */ + 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); + } + + /** + *
+	 * Updates an employee record by setting the phone number.
+     * 
+ */ + 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); + } + + /** + *
+	 * Performs an SQL-Query and prints the result to System.out
+	 * 
+	 * First a DBCommand object is used to create the following SQL-Query (Oracle-Syntax):
+     *     
+     *   SELECT t2.EMPLOYEE_ID, t2.LASTNAME || ', ' || t2.FIRSTNAME AS FULL_NAME, t2.GENDER, t2.PHONE_NUMBER, 
+     *          substr(t2.PHONE_NUMBER, length(t2.PHONE_NUMBER)-instr(reverse(t2.PHONE_NUMBER), '-')+2) AS PHONE_EXTENSION, 
+     *          t1.NAME AS DEPARTMENT, t1.BUSINESS_UNIT
+     *   FROM EMPLOYEES t2 INNER JOIN DEPARTMENTS t1 ON t1.DEPARTMENT_ID = t2.DEPARTMENT_ID
+     *   WHERE length(t2.LASTNAME)>0
+     *   ORDER BY t2.LASTNAME, t2.FIRSTNAME
+     * 
+	 * For processing the rows there are three options available:
+	 * 
+	 *   QueryType.Reader:
+	 *     Interates through all rows and prints field values as tabbed text.
+	 *      
+     *   QueryType.BeanList:
+     *     Obtains the query result as a list of JavaBean objects of type SampleBean.
+     *     It then iterates throuh the list of beans and uses bean.toString() for printing.
+     *     
+     *   QueryType.XmlDocument:
+     *     Obtains the query result as an XML-Document and prints the document.
+     *     Please note, that the XML not only contains the data but also the field metadata.
+     * 
+ */ + private static void queryRecords(Connection conn, QueryType queryType) + { + // Define the query + DBCommand cmd = db.createCommand(); + // Define shortcuts for tables used - not necessary but convenient + SampleDB.Employees EMP = db.EMPLOYEES; + SampleDB.Departments DEP = db.DEPARTMENTS; + + // The following expression concats lastname + ', ' + firstname + DBColumnExpr EMPLOYEE_FULLNAME = EMP.LASTNAME.append(", ").append(EMP.FIRSTNAME).as("FULL_NAME"); + + // The following expression extracts the extension number from the phone field + // e.g. substr(PHONE_NUMBER, length(PHONE_NUMBER)-instr(reverse(PHONE_NUMBER), '-')+2) AS PHONE_EXTENSION + // Hint: Since the reverse() function is not supported by HSQLDB there is special treatment for HSQL + DBColumnExpr PHONE_LAST_DASH; + if ( db.getDriver() instanceof DBDatabaseDriverHSql ) + PHONE_LAST_DASH = EMP.PHONE_NUMBER.indexOf("-", EMP.PHONE_NUMBER.indexOf("-").plus(1)).plus(1); // HSQLDB only + else PHONE_LAST_DASH = EMP.PHONE_NUMBER.length().minus(EMP.PHONE_NUMBER.reverse().indexOf("-")).plus(2); + DBColumnExpr PHONE_EXT_NUMBER = EMP.PHONE_NUMBER.substring(PHONE_LAST_DASH).as("PHONE_EXTENSION"); + + // DBColumnExpr genderExpr = cmd.select(EMP.GENDER.decode(EMP.GENDER.getOptions()).as(EMP.GENDER.getName())); + // Select requried columns + cmd.select(EMP.EMPLOYEE_ID, EMPLOYEE_FULLNAME); + cmd.select(EMP.GENDER, EMP.PHONE_NUMBER, PHONE_EXT_NUMBER); + cmd.select(DEP.NAME.as("DEPARTMENT")); + cmd.select(DEP.BUSINESS_UNIT); + cmd.join(EMP.DEPARTMENT_ID, DEP.DEPARTMENT_ID); + // Set contraints and order + cmd.where(EMP.LASTNAME.length().isGreaterThan(0)); + cmd.orderBy(EMP.LASTNAME); + cmd.orderBy(EMP.FIRSTNAME); + + // Query Records and print output + DBReader reader = new DBReader(); + try + { + // Open Reader + System.out.println("Running Query:"); + System.out.println(cmd.getSelect()); + reader.open(cmd, conn); + // Print output + System.out.println("---------------------------------"); + switch(queryType) + { + case Reader: + // Text-Output by iterating through all records. + while (reader.moveNext()) + { + System.out.println(reader.getString(EMP.EMPLOYEE_ID) + + "\t" + reader.getString(EMPLOYEE_FULLNAME) + + "\t" + EMP.GENDER.getOptions().get(reader.getString(EMP.GENDER)) + + "\t" + reader.getString(PHONE_EXT_NUMBER) + + "\t" + reader.getString(DEP.NAME)); + } + break; + case BeanList: + // Text-Output using a list of Java Beans supplied by the DBReader + List beanList = reader.getBeanList(SampleBean.class); + System.out.println(String.valueOf(beanList.size()) + " SampleBeans returned from Query."); + for (SampleBean b : beanList) + { + System.out.println(b.toString()); + } + break; + case XmlDocument: + // XML Output + Document doc = reader.getXmlDocument(); + // Print XML Document to System.out + XMLWriter.debug(doc); + break; + } + + } finally + { + // always close Reader + reader.close(); + } + } + +} Added: incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleBean.java URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleBean.java?rev=683184&view=auto ============================================================================== --- incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleBean.java (added) +++ incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleBean.java Wed Aug 6 02:04:56 2008 @@ -0,0 +1,111 @@ +/* + * ESTEAM Software GmbH, 09.12.2007 + */ +package org.apache.empire.samples.db; + + +/** + * The SampleBean class is used to demonstrate JavaBean support for SQL-Queries. + * The SampleBean is used in the SampleApp's queryRecords function. + */ +public class SampleBean +{ + private int employeeId; + private String fullName; + private String gender; + private String phoneNumber; + private String department; + private String businessUnit; + + /* + * Uncomment this if you want to use constructor instead of setters + * However, number of arguments and data types must match query! + * + public SampleBean(int employeeId, String fullName, String gender, String phoneNumber, String department, String businessUnit) + { + this.employeeId = employeeId; + this.fullName = fullName; + this.gender = gender; + this.phoneNumber = phoneNumber; + this.department = department; + this.businessUnit = businessUnit; + } + */ + + public int getEmployeeId() + { + return employeeId; + } + + public void setEmployeeId(int employeeId) + { + this.employeeId = employeeId; + } + + public String getFullName() + { + return fullName; + } + + public void setFullName(String fullName) + { + this.fullName = fullName; + } + + public String getGender() + { + return gender; + } + + public void setGender(String gender) + { + this.gender = gender; + } + + public String getPhoneNumber() + { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) + { + this.phoneNumber = phoneNumber; + } + + public String getDepartment() + { + return department; + } + + public void setDepartment(String department) + { + this.department = department; + } + + public String getBusinessUnit() + { + return businessUnit; + } + + public void setBusinessUnit(String businessUnit) + { + this.businessUnit = businessUnit; + } + + @Override + public String toString() + { + StringBuffer buf = new StringBuffer(); + buf.append(employeeId); + buf.append("\t"); + buf.append(fullName); + buf.append("\t"); + buf.append(gender); + buf.append("\t"); + buf.append(department); + buf.append("\t"); + buf.append(businessUnit); + return buf.toString(); + } + +} Added: incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleConfig.java URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleConfig.java?rev=683184&view=auto ============================================================================== --- incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleConfig.java (added) +++ incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleConfig.java Wed Aug 6 02:04:56 2008 @@ -0,0 +1,104 @@ +package org.apache.empire.samples.db; + +import org.apache.empire.xml.XMLConfiguration; + +/** + *
+ * The SampleConfig class provides access to configuration settings.
+ * The configruation will be read from a xml configuration file (usually config.xml) 
+ * Thus the default values here will be overridden. 
+ * 
+ */ +public class SampleConfig extends XMLConfiguration +{ + + private String databaseProvider = "hsqldb"; + + private String jdbcClass = "org.hsqldb.jdbcDriver"; + + private String jdbcURL = "jdbc:hsqldb:file:hsqldb/sample;shutdown=true"; + + private String jdbcUser = "jdbc:hsqldb:file:hsqldb/sample;shutdown=true"; + + private String jdbcPwd = ""; + + private String schemaName = "DBSAMPLE"; + + /** + * Initialize the configuration. + */ + public boolean init(String filename) + { + // Read the properties file + if (super.init(filename, false, true) == false) + return false; + // Done + if (readProperties(this, "properties")==false) + return false; + // Reader Provider Properties + return readProperties(this, "properties-" + databaseProvider); + } + + public String getDatabaseProvider() + { + return databaseProvider; + } + + public String getJdbcClass() + { + return jdbcClass; + } + + public void setJdbcClass(String jdbcClass) + { + this.jdbcClass = jdbcClass; + } + + public String getJdbcPwd() + { + return jdbcPwd; + } + + public void setJdbcPwd(String jdbcPwd) + { + this.jdbcPwd = jdbcPwd; + } + + public String getJdbcURL() + { + return jdbcURL; + } + + public String getSchemaName() + { + return schemaName; + } + + // ------- Setters ------- + + public void setDatabaseProvider(String databaseProvider) + { + this.databaseProvider = databaseProvider; + } + + public void setJdbcURL(String jdbcURL) + { + this.jdbcURL = jdbcURL; + } + + public String getJdbcUser() + { + return jdbcUser; + } + + public void setJdbcUser(String jdbcUser) + { + this.jdbcUser = jdbcUser; + } + + public void setSchemaName(String schemaName) + { + this.schemaName = schemaName; + } + +} Added: incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleDB.java URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleDB.java?rev=683184&view=auto ============================================================================== --- incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleDB.java (added) +++ incubator/empire-db/trunk/core/DBSample/src/org/apache/empire/samples/db/SampleDB.java Wed Aug 6 02:04:56 2008 @@ -0,0 +1,122 @@ +package org.apache.empire.samples.db; + +import org.apache.empire.commons.Options; +import org.apache.empire.data.DataType; +import org.apache.empire.db.DBColumn; +import org.apache.empire.db.DBDatabase; +import org.apache.empire.db.DBTable; +import org.apache.empire.db.DBTableColumn; + +/** + *
+ * This file contains the definition of the data model in Java.
+ * The SampleDB data model consists of two tables and a foreign key relation.
+ * The tables are defined as nested classes here, but you may put the in separate files if you want.
+ *
+ * PLEASE NOTE THE NAMING CONVENTION:
+ * Since all tables, views and columns are declared as "final" constants they are all in upper case.
+ * We recommend using a prefix of T_ for tables and C_ for columns in order to keep them togehter
+ * when listed in your IDE's code completition.
+ * There is no need to stick to this convention but it makes life just another little bit easier.
+ *
+ * You may declare other database tables or views in the same way.
+ * 
+ */ +public class SampleDB extends DBDatabase +{ + /** + * This class represents the definition of the Departments table. + */ + public static class Departments extends DBTable + { + public final DBTableColumn DEPARTMENT_ID; + public final DBTableColumn NAME; + public final DBTableColumn HEAD; + public final DBTableColumn BUSINESS_UNIT; + public final DBTableColumn UPDATE_TIMESTAMP; + + public Departments(DBDatabase db) + { + super("DEPARTMENTS", db); + // ID + DEPARTMENT_ID = addColumn("DEPARTMENT_ID", DataType.AUTOINC, 0, true, "DEP_ID_SEQUENCE"); + NAME = addColumn("NAME", DataType.TEXT, 80, true); + HEAD = addColumn("HEAD", DataType.TEXT, 80, false); + BUSINESS_UNIT = addColumn("BUSINESS_UNIT", DataType.TEXT, 4, true, "ITTK"); + UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME, 0, true); + + // Primary Key + setPrimaryKey(DEPARTMENT_ID); + // Set other Indexes + addIndex("DEARTMENT_NAME_IDX", true, new DBColumn[] { NAME }); + // Set timestamp column for save updates + setTimestampColumn(UPDATE_TIMESTAMP); + } + } + + /** + * This class represents the definition of the Employees table. + */ + public static class Employees extends DBTable + { + public final DBTableColumn EMPLOYEE_ID; + public final DBTableColumn SALUTATION; + public final DBTableColumn FIRSTNAME; + public final DBTableColumn LASTNAME; + public final DBTableColumn DATE_OF_BIRTH; + public final DBTableColumn DEPARTMENT_ID; + public final DBTableColumn GENDER; + public final DBTableColumn PHONE_NUMBER; + public final DBTableColumn EMAIL; + public final DBTableColumn SALARY; + public final DBTableColumn RETIRED; + public final DBTableColumn UPDATE_TIMESTAMP; + + public Employees(DBDatabase db) + { + super("EMPLOYEES", db); + // ID + EMPLOYEE_ID = addColumn("EMPLOYEE_ID", DataType.AUTOINC, 0, true, "EMPLOYEE_ID_SEQUENCE"); + SALUTATION = addColumn("SALUTATION", DataType.TEXT, 20, false); + FIRSTNAME = addColumn("FIRSTNAME", DataType.TEXT, 40, true); + LASTNAME = addColumn("LASTNAME", DataType.TEXT, 40, true); + DATE_OF_BIRTH = addColumn("DATE_OF_BIRTH", DataType.DATE, 0, false); + DEPARTMENT_ID = addColumn("DEPARTMENT_ID", DataType.INTEGER, 0, true); + GENDER = addColumn("GENDER", DataType.TEXT, 1, false); + PHONE_NUMBER = addColumn("PHONE_NUMBER", DataType.TEXT, 40, false); + EMAIL = addColumn("EMAIL", DataType.TEXT, 80, false); + SALARY = addColumn("SALARY", DataType.DECIMAL, 10.2, false); + RETIRED = addColumn("RETIRED", DataType.BOOL, 0, true, false); + UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME, 0, true); + + // Primary Key + setPrimaryKey(EMPLOYEE_ID); + // Set other Indexes + addIndex("EMPLOYEE_NAME_IDX", true, new DBColumn[] { FIRSTNAME, LASTNAME, DATE_OF_BIRTH }); + // Set timestamp column for save updates + setTimestampColumn(UPDATE_TIMESTAMP); + + // Create Options for GENDER column + Options genders = new Options(); + genders.set("M", "Male"); + genders.set("F", "Female"); + GENDER.setOptions(genders); + } + } + + // Declare all Tables and Views here + public final Departments DEPARTMENTS = new Departments(this); + public final Employees EMPLOYEES = new Employees(this); + + /** + * Constructor of the SampleDB data model description + * + * Put all foreigen key realtions here. + */ + public SampleDB() + { + // Define Foreign-Key Relations + addRelation( EMPLOYEES.DEPARTMENT_ID.referenceOn( DEPARTMENTS.DEPARTMENT_ID )); + } + +} Added: incubator/empire-db/trunk/core/DBSample/tutorial.pdf URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/DBSample/tutorial.pdf?rev=683184&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/empire-db/trunk/core/DBSample/tutorial.pdf ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream