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 do...@apache.org on 2009/09/20 22:25:45 UTC
svn commit: r817095 - in /incubator/empire-db/trunk/empire-db-codegen: ./
src/ src/main/ src/main/java/ src/main/resources/ src/test/ src/test/java/
src/test/java/org/ src/test/java/org/apache/
src/test/java/org/apache/empire/ src/test/java/org/apache/...
Author: doebele
Date: Sun Sep 20 20:25:45 2009
New Revision: 817095
URL: http://svn.apache.org/viewvc?rev=817095&view=rev
Log:
EMPIREDB-52
Added:
incubator/empire-db/trunk/empire-db-codegen/config.xml (with props)
incubator/empire-db/trunk/empire-db-codegen/pom.xml (with props)
incubator/empire-db/trunk/empire-db-codegen/src/ (with props)
incubator/empire-db/trunk/empire-db-codegen/src/main/ (with props)
incubator/empire-db/trunk/empire-db-codegen/src/main/java/ (with props)
incubator/empire-db/trunk/empire-db-codegen/src/main/resources/ (with props)
incubator/empire-db/trunk/empire-db-codegen/src/test/ (with props)
incubator/empire-db/trunk/empire-db-codegen/src/test/java/ (with props)
incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/ (with props)
incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/ (with props)
incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/ (with props)
incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/ (with props)
incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/ (with props)
incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGen.java (with props)
incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenConfig.java (with props)
incubator/empire-db/trunk/empire-db-codegen/src/test/resources/ (with props)
Added: incubator/empire-db/trunk/empire-db-codegen/config.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/config.xml?rev=817095&view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/config.xml (added)
+++ incubator/empire-db/trunk/empire-db-codegen/config.xml Sun Sep 20 20:25:45 2009
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ -->
+<config>
+
+ <properties>
+ <!-- provider name must match the property-section containing the connection data -->
+ <jdbcClass>oracle.jdbc.driver.OracleDriver</jdbcClass>
+ <jdbcURL>jdbc:oracle:thin:@192.168.0.2:1521:ora10</jdbcURL>
+ <jdbcUser>DBSAMPLE</jdbcUser>
+ <jdbcPwd>DBSAMPLE</jdbcPwd>
+ </properties>
+
+ <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <appender name="default" class="org.apache.log4j.ConsoleAppender">
+ <!-- layout class="org.apache.log4j.TTCCLayout"/ -->
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- param name="ConversionPattern" value="NSB(%c) %-5p %m at %l%n"/ -->
+ <param name="ConversionPattern" value="%-5p [%d{yyyy/MM/dd HH:mm}]: %m at %l %n"/>
+ </layout>
+ </appender>
+
+ <!-- log detail configuration -->
+ <logger name="org.apache.empire.commons" additivity="false">
+ <level value="warn"/>
+ <appender-ref ref="default"/>
+ </logger>
+
+ <root>
+ <priority value="info"/>
+ <appender-ref ref="default"/>
+ </root>
+
+ </log4j:configuration>
+
+</config>
Propchange: incubator/empire-db/trunk/empire-db-codegen/config.xml
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/trunk/empire-db-codegen/config.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/trunk/empire-db-codegen/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/pom.xml?rev=817095&view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/pom.xml (added)
+++ incubator/empire-db/trunk/empire-db-codegen/pom.xml Sun Sep 20 20:25:45 2009
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>empire-db-parent</artifactId>
+ <groupId>org.apache.empire-db</groupId>
+ <version>2.0.6-incubating-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.empire-db</groupId>
+ <artifactId>empire-db-codegen</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Empire-db Code Generator</name>
+ <dependencies>
+
+ <!-- Code dependencies -->
+ <dependency>
+ <groupId>org.apache.empire-db</groupId>
+ <artifactId>empire-db</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>1.6.2</version>
+ </dependency>
+
+ <!-- Databases -->
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <!-- <scope>runtime</scope> -->
+ </dependency>
+ <!-- other
+ <dependency>
+ <groupId>ojdbc</groupId>
+ <artifactId>ojdbc</artifactId>
+ <version>14</version>
+ </dependency>
+ -->
+ </dependencies>
+</project>
\ No newline at end of file
Propchange: incubator/empire-db/trunk/empire-db-codegen/pom.xml
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/trunk/empire-db-codegen/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Propchange: incubator/empire-db/trunk/empire-db-codegen/src/
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/java/
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/trunk/empire-db-codegen/src/test/
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/trunk/empire-db-codegen/src/test/java/
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/
------------------------------------------------------------------------------
eol-style = native
Added: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGen.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGen.java?rev=817095&view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGen.java (added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGen.java Sun Sep 20 20:25:45 2009
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.codegen;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.DriverManager;
+import java.util.logging.Logger;
+
+import org.apache.empire.commons.ErrorObject;
+
+public class CodeGen
+{
+ public static Logger logger = Logger.getLogger(CodeGen.class.getName());
+
+ private static CodeGenConfig config = new CodeGenConfig();
+
+ /**
+ * <PRE>
+ * This is the entry point of the Empire-DB Sample Application
+ * Please check the config.xml configuration file for Database and Connection settings.
+ * </PRE>
+ * @param args arguments
+ */
+ public static void main(String[] args)
+ {
+ Connection conn = null;
+ try
+ {
+ // Init Configuration
+ config.init((args.length > 0 ? args[0] : "config.xml" ), false, true);
+
+ // Enable Exceptions
+ ErrorObject.setExceptionsEnabled(true);
+
+ // Get a JDBC Connection
+ conn = getJDBCConnection();
+
+ // Get Metadata
+ DatabaseMetaData dmd = conn.getMetaData();
+
+ // Process Metadata
+ // ....
+
+ } catch(Exception e) {
+ // Error
+ System.out.println(e.toString());
+ e.printStackTrace();
+ } finally {
+ // done
+ if (conn!=null)
+ close(conn);
+ }
+ }
+
+ /**
+ * <PRE>
+ * 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.
+ * </PRE>
+ */
+ 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(true);
+ 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;
+ }
+
+ /**
+ * Closes a JDBC-Connection.
+ */
+ private static void close(Connection conn)
+ {
+ logger.info("Closing database connection");
+ try {
+ conn.close();
+ } catch (Exception e) {
+ logger.severe("Error closing connection");
+ logger.severe(e.toString());
+ }
+ }
+
+}
Propchange: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGen.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGen.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenConfig.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenConfig.java?rev=817095&view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenConfig.java (added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenConfig.java Sun Sep 20 20:25:45 2009
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.codegen;
+
+import org.apache.empire.xml.XMLConfiguration;
+
+public class CodeGenConfig extends XMLConfiguration
+{
+ private String jdbcClass = "org.hsqldb.jdbcDriver";
+
+ private String jdbcURL = "jdbc:hsqldb:file:hsqldb/sample;shutdown=true";
+
+ private String jdbcUser = "sa";
+
+ private String jdbcPwd = "";
+
+ public String getJdbcClass()
+ {
+ return jdbcClass;
+ }
+
+ public void setJdbcClass(String jdbcClass)
+ {
+ this.jdbcClass = jdbcClass;
+ }
+
+ public String getJdbcURL()
+ {
+ return jdbcURL;
+ }
+
+ public void setJdbcURL(String jdbcURL)
+ {
+ this.jdbcURL = jdbcURL;
+ }
+
+ public String getJdbcUser()
+ {
+ return jdbcUser;
+ }
+
+ public void setJdbcUser(String jdbcUser)
+ {
+ this.jdbcUser = jdbcUser;
+ }
+
+ public String getJdbcPwd()
+ {
+ return jdbcPwd;
+ }
+
+ public void setJdbcPwd(String jdbcPwd)
+ {
+ this.jdbcPwd = jdbcPwd;
+ }
+
+}
Propchange: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenConfig.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenConfig.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Propchange: incubator/empire-db/trunk/empire-db-codegen/src/test/resources/
------------------------------------------------------------------------------
eol-style = native