You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by fr...@apache.org on 2009/02/26 22:38:23 UTC
svn commit: r748322 - in /incubator/empire-db/trunk:
empire-db-examples/empire-db-example-advanced/
empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/
empire-db/src/main/java/org/apache/empire/db/h2/
Author: francisdb
Date: Thu Feb 26 21:38:22 2009
New Revision: 748322
URL: http://svn.apache.org/viewvc?rev=748322&view=rev
Log:
fixed h2 driver
added exception for the advanced app if h2 driver (can't alter table with view)
son't store files in user home dir for h2
Modified:
incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/config.xml
incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/h2/DBDatabaseDriverH2.java
Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/config.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/config.xml?rev=748322&r1=748321&r2=748322&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/config.xml (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/config.xml Thu Feb 26 21:38:22 2009
@@ -23,7 +23,7 @@
<properties>
<!-- provider name must match the property-section containing the connection data -->
- <databaseProvider>hsqldb</databaseProvider>
+ <databaseProvider>derby</databaseProvider>
</properties>
<properties-hsqldb>
@@ -80,7 +80,7 @@
<!-- JDBC properties for a H2 Database connection -->
<!-- Required jar file: h2-1.1.107.jar -->
<jdbcClass>org.h2.Driver</jdbcClass>
- <jdbcURL>jdbc:h2:~/h2test/DBSAMPLE</jdbcURL>
+ <jdbcURL>jdbc:h2:h2/DBSAMPLE</jdbcURL>
<jdbcUser>sa</jdbcUser>
<jdbcPwd></jdbcPwd>
<schemaName>DBSAMPLEADV</schemaName>
@@ -90,7 +90,7 @@
<!-- JDBC properties for a Derby Database connection -->
<!-- Required jar file: derby-10.4.2.0.jar -->
<jdbcClass>org.apache.derby.jdbc.EmbeddedDriver</jdbcClass>
- <jdbcURL>jdbc:derby:DBSAMPLE;create=true</jdbcURL>
+ <jdbcURL>jdbc:derby:derby/DBSAMPLE;create=true</jdbcURL>
<jdbcUser></jdbcUser>
<jdbcPwd></jdbcPwd>
<schemaName>DBSAMPLEADV</schemaName>
@@ -131,7 +131,7 @@
<!-- Set this level to "debug" to log all DDL-Statements -->
<logger name="org.apache.empire.db.DBSQLScript" additivity="false">
- <level value="info"/>
+ <level value="debug"/>
<appender-ref ref="default"/>
</logger>
Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java?rev=748322&r1=748321&r2=748322&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java Thu Feb 26 21:38:22 2009
@@ -24,6 +24,7 @@
import java.util.HashMap;
import java.util.logging.Logger;
+import org.apache.empire.EmpireException;
import org.apache.empire.commons.DateUtils;
import org.apache.empire.commons.ErrorObject;
import org.apache.empire.commons.Options;
@@ -169,10 +170,24 @@
querySample(conn, idPers2);
}
// STEP 11: ddlSample
- if (true) {
- System.out.println("*** ddlSample: shows how to add a column at runtime and update a record with the added column ***");
- ddlSample(conn, idPers2);
- }
+ if (true) {
+ 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) {
+ logger.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, idPers2);
+ if (db.getDriver() instanceof DBDatabaseDriverH2) {
+ logger.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);
+ }
+ }
// Done
System.out.println("DB Sample finished successfully.");
Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/h2/DBDatabaseDriverH2.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/h2/DBDatabaseDriverH2.java?rev=748322&r1=748321&r2=748322&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/h2/DBDatabaseDriverH2.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/h2/DBDatabaseDriverH2.java Thu Feb 26 21:38:22 2009
@@ -654,7 +654,7 @@
appendColumnDesc(col, sql);
break;
case ALTER:
- sql.append(" MODIFY ");
+ sql.append(" ALTER ");
appendColumnDesc(col, sql);
break;
case DROP: