empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From franci...@apache.org
Subject svn commit: r747590 - /incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
Date Tue, 24 Feb 2009 22:44:54 GMT
Author: francisdb
Date: Tue Feb 24 22:44:53 2009
New Revision: 747590

URL: http://svn.apache.org/viewvc?rev=747590&view=rev
Log:
no transactions for DDL when using prostgres
exclude missing operation for prostgres

Modified:
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java?rev=747590&r1=747589&r2=747590&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
Tue Feb 24 22:44:53 2009
@@ -77,6 +77,7 @@
 
 			// STEP 1: Get a JDBC Connection
 			System.out.println("*** Step 1: getJDBCConnection() ***");
+			
 			Connection conn = getJDBCConnection();
 
 			// STEP 2: Choose a driver
@@ -93,7 +94,16 @@
 			} catch(Exception e) {
                 // STEP 4: Create Database
                 System.out.println("*** Step 4: createDDL() ***");
+                // postgre does not support DDL in transaction
+                if(db.getDriver() instanceof DBDatabaseDriverPostgreSQL)
+                {
+                	conn.setAutoCommit(true);
+                }
                 createDatabase(driver, conn);
+                if(db.getDriver() instanceof DBDatabaseDriverPostgreSQL)
+                {
+                	conn.setAutoCommit(false);
+                }
                 // Open again
                 if (db.isOpen()==false)
                     db.open(driver, conn);
@@ -165,7 +175,7 @@
 			logger.info("Connected successfully");
 			// set the AutoCommit to false this session. You must commit
 			// explicitly now
-			conn.setAutoCommit(false);
+			conn.setAutoCommit(true);
 			logger.info("AutoCommit is " + conn.getAutoCommit());
 
 		} catch (Exception e)
@@ -392,7 +402,14 @@
         // 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);
+		if(db.getDriver() instanceof DBDatabaseDriverPostgreSQL)
+		{
+			// postgresql does not support the substring expression
+			cmd.select(EMP.GENDER, EMP.PHONE_NUMBER);
+		}else{
+			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);



Mime
View raw message