db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r373388 - in /db/ddlutils/trunk: ./ src/java/org/apache/ddlutils/ src/java/org/apache/ddlutils/platform/oracle/ src/test/
Date Sun, 29 Jan 2006 23:12:24 GMT
Author: tomdz
Date: Sun Jan 29 15:12:12 2006
New Revision: 373388

URL: http://svn.apache.org/viewcvs?rev=373388&view=rev
Log:
Added Oracle 10 platform
Enhanced/fixed Oracle platforms

Added:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java
      - copied, changed from r372576, db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/OracleBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8ModelReader.java
      - copied, changed from r372576, db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/OracleModelReader.java
Removed:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/OracleBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/OracleModelReader.java
Modified:
    db/ddlutils/trunk/.classpath
    db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformFactory.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Platform.java
    db/ddlutils/trunk/src/test/jdbc.properties.oracle9

Modified: db/ddlutils/trunk/.classpath
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/.classpath?rev=373388&r1=373387&r2=373388&view=diff
==============================================================================
--- db/ddlutils/trunk/.classpath (original)
+++ db/ddlutils/trunk/.classpath Sun Jan 29 15:12:12 2006
@@ -15,5 +15,6 @@
 	<classpathentry kind="lib" path="lib/commons-betwixt-0.8-dev.jar"/>
 	<classpathentry sourcepath="E:/development/commons-lang-2.1/src/java" kind="lib" path="lib/commons-lang-2.1.jar"/>
 	<classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/>
+	<classpathentry kind="lib" path="lib/jakarta-oro-2.0.8.jar"/>
 	<classpathentry kind="output" path="target/classes"/>
 </classpath>

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformFactory.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformFactory.java?rev=373388&r1=373387&r2=373388&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformFactory.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformFactory.java Sun Jan 29 15:12:12
2006
@@ -31,6 +31,7 @@
 import org.apache.ddlutils.platform.mssql.MSSqlPlatform;
 import org.apache.ddlutils.platform.mysql.MySqlPlatform;
 import org.apache.ddlutils.platform.mysql.MySql50Platform;
+import org.apache.ddlutils.platform.oracle.Oracle10Platform;
 import org.apache.ddlutils.platform.oracle.Oracle8Platform;
 import org.apache.ddlutils.platform.oracle.Oracle9Platform;
 import org.apache.ddlutils.platform.postgresql.PostgreSqlPlatform;
@@ -192,6 +193,7 @@
         addPlatform(_platforms, MySql50Platform.DATABASENAME,    MySql50Platform.class);
         addPlatform(_platforms, Oracle8Platform.DATABASENAME,    Oracle8Platform.class);
         addPlatform(_platforms, Oracle9Platform.DATABASENAME,    Oracle9Platform.class);
+        addPlatform(_platforms, Oracle10Platform.DATABASENAME,   Oracle10Platform.class);
         addPlatform(_platforms, PostgreSqlPlatform.DATABASENAME, PostgreSqlPlatform.class);
         addPlatform(_platforms, SapDbPlatform.DATABASENAME,      SapDbPlatform.class);
         addPlatform(_platforms, SybasePlatform.DATABASENAME,     SybasePlatform.class);

Copied: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java
(from r372576, db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/OracleBuilder.java)
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java?p2=db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java&p1=db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/OracleBuilder.java&r1=372576&r2=373388&rev=373388&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/OracleBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java Sun
Jan 29 15:12:12 2006
@@ -1,7 +1,7 @@
 package org.apache.ddlutils.platform.oracle;
 
 /*
- * Copyright 1999-2006 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,22 @@
  */
 
 import java.io.IOException;
+import java.sql.Types;
 import java.util.Map;
 
+import org.apache.ddlutils.DdlUtilsException;
 import org.apache.ddlutils.PlatformInfo;
 import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.Database;
 import org.apache.ddlutils.model.Table;
+import org.apache.ddlutils.model.TypeMap;
 import org.apache.ddlutils.platform.SqlBuilder;
+import org.apache.ddlutils.util.Jdbc3Utils;
+import org.apache.oro.text.regex.MalformedPatternException;
+import org.apache.oro.text.regex.Pattern;
+import org.apache.oro.text.regex.PatternCompiler;
+import org.apache.oro.text.regex.Perl5Compiler;
+import org.apache.oro.text.regex.Perl5Matcher;
 
 /**
  * The SQL Builder for Oracle.
@@ -32,16 +41,36 @@
  * @author Thomas Dudziak
  * @version $Revision$
  */
-public class OracleBuilder extends SqlBuilder
+public class Oracle8Builder extends SqlBuilder
 {
-    /**
+	/** The regular expression pattern for ISO dates, i.e. 'YYYY-MM-DD'. */
+	private Pattern _isoDatePattern;
+	/** The regular expression pattern for ISO times, i.e. 'HH:MI:SS'. */
+	private Pattern _isoTimePattern;
+	/** The regular expression pattern for ISO timestamps, i.e. 'YYYY-MM-DD HH:MI:SS.fffffffff'.
*/
+	private Pattern _isoTimestampPattern;
+
+	/**
      * Creates a new builder instance.
      * 
      * @param info The platform info
      */
-    public OracleBuilder(PlatformInfo info)
+    public Oracle8Builder(PlatformInfo info)
     {
         super(info);
+
+        PatternCompiler compiler = new Perl5Compiler();
+
+    	try
+    	{
+            _isoDatePattern      = compiler.compile("\\d{4}\\-\\d{2}\\-\\d{2}");
+            _isoTimePattern      = compiler.compile("\\d{2}:\\d{2}:\\d{2}");
+            _isoTimestampPattern = compiler.compile("\\d{4}\\-\\d{2}\\-\\d{2} \\d{2}:\\d{2}:\\d{2}[\\.\\d{1,8}]?");
+        }
+    	catch (MalformedPatternException ex)
+        {
+        	throw new DdlUtilsException(ex);
+        }
     }
 
     /**
@@ -104,10 +133,65 @@
             printIdentifier(getConstraintName("seq", table, columns[idx].getName(), null));
             print(".nextval INTO :new.");
             printIdentifier(getColumnName(columns[idx]));
-            println(" FROM dual;");
-            print("END");
+            print(" FROM dual");
             printEndOfStatement();
         }
+    }
+
+	/**
+     * {@inheritDoc}
+     */
+    protected void writeColumnDefaultValue(Table table, Column column) throws IOException
+    {
+        String  nativeDefault   = getNativeDefaultValue(column);
+        boolean shouldUseQuotes = !TypeMap.isNumericType(column.getTypeCode()) &&
!nativeDefault.startsWith("TO_DATE(");
+
+        if (shouldUseQuotes)
+        {
+            print(getPlatformInfo().getValueQuoteToken());
+        }
+        print(getNativeDefaultValue(column).toString());
+        if (shouldUseQuotes)
+        {
+            print(getPlatformInfo().getValueQuoteToken());
+        }
+	}
+
+	/**
+     * {@inheritDoc}
+     */
+    protected String getNativeDefaultValue(Column column)
+    {
+        if ((column.getTypeCode() == Types.BIT) ||
+            (Jdbc3Utils.supportsJava14JdbcTypes() && (column.getTypeCode() == Jdbc3Utils.determineBooleanTypeCode())))
+        {
+            return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(),
Types.SMALLINT).toString();
+        }
+    	// Oracle does not accept ISO formats, so we have to convert an ISO spec if we find
one
+    	// But these are the only formats that we make sure work, every other format has to
be database-dependent
+    	// and thus the user has to ensure that it is correct
+        else if (column.getTypeCode() == Types.DATE)
+        {
+            if (new Perl5Matcher().matches(column.getDefaultValue(), _isoDatePattern))
+            {
+            	return "TO_DATE('"+column.getDefaultValue()+"', 'YYYY-MM-DD')";
+            }
+        }
+        else if (column.getTypeCode() == Types.TIME)
+        {
+            if (new Perl5Matcher().matches(column.getDefaultValue(), _isoTimePattern))
+            {
+            	return "TO_DATE('"+column.getDefaultValue()+"', 'HH24:MI:SS')";
+            }
+        }
+        else if (column.getTypeCode() == Types.TIMESTAMP)
+        {
+            if (new Perl5Matcher().matches(column.getDefaultValue(), _isoTimestampPattern))
+            {
+            	return "TO_DATE('"+column.getDefaultValue()+"', 'YYYY-MM-DD HH24:MI:SS')";
+            }
+        }
+        return super.getNativeDefaultValue(column);
     }
 
     /**

Copied: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8ModelReader.java
(from r372576, db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/OracleModelReader.java)
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8ModelReader.java?p2=db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8ModelReader.java&p1=db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/OracleModelReader.java&r1=372576&r2=373388&rev=373388&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/OracleModelReader.java
(original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8ModelReader.java
Sun Jan 29 15:12:12 2006
@@ -16,27 +16,237 @@
  * limitations under the License.
  */
 
+import java.sql.DatabaseMetaData;
+import java.sql.Date;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.sql.Types;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.collections.map.ListOrderedMap;
+import org.apache.ddlutils.DdlUtilsException;
 import org.apache.ddlutils.PlatformInfo;
+import org.apache.ddlutils.model.Column;
+import org.apache.ddlutils.platform.DatabaseMetaDataWrapper;
 import org.apache.ddlutils.platform.JdbcModelReader;
+import org.apache.oro.text.regex.MalformedPatternException;
+import org.apache.oro.text.regex.Pattern;
+import org.apache.oro.text.regex.PatternCompiler;
+import org.apache.oro.text.regex.PatternMatcher;
+import org.apache.oro.text.regex.Perl5Compiler;
+import org.apache.oro.text.regex.Perl5Matcher;
 
 /**
- * Reads a database model from a Oracle database.
+ * Reads a database model from an Oracle 8 database.
  *
  * @author Thomas Dudziak
  * @version $Revision: $
  */
-public class OracleModelReader extends JdbcModelReader
+public class Oracle8ModelReader extends JdbcModelReader
 {
-    /**
-     * Creates a new model reader for Oracle databases.
+	/** The regular expression pattern for the Oracle concersion of ISO dates. */
+	private Pattern _oracleIsoDatePattern;
+	/** The regular expression pattern for the Oracle concersion of ISO times. */
+	private Pattern _oracleIsoTimePattern;
+	/** The regular expression pattern for the Oracle concersion of ISO timestamps. */
+	private Pattern _oracleIsoTimestampPattern;
+
+	/**
+     * Creates a new model reader for Oracle 8 databases.
      * 
      * @param platformInfo The platform specific settings
      */
-    public OracleModelReader(PlatformInfo platformInfo)
+    public Oracle8ModelReader(PlatformInfo platformInfo)
     {
         super(platformInfo);
         setDefaultCatalogPattern(null);
         setDefaultSchemaPattern(null);
         setDefaultTablePattern("%");
+
+        PatternCompiler compiler = new Perl5Compiler();
+
+    	try
+    	{
+    		_oracleIsoDatePattern      = compiler.compile("TO_DATE\\('([^']*)'\\, 'YYYY\\-MM\\-DD'\\)");
+    		_oracleIsoTimePattern      = compiler.compile("TO_DATE\\('([^']*)'\\, 'HH24:MI:SS'\\)");
+    		_oracleIsoTimestampPattern = compiler.compile("TO_DATE\\('([^']*)'\\, 'YYYY\\-MM\\-DD
HH24:MI:SS'\\)");
+        }
+    	catch (MalformedPatternException ex)
+        {
+        	throw new DdlUtilsException(ex);
+        }
     }
+
+	/**
+     * {@inheritDoc}
+     */
+    protected Column readColumn(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
+    {
+		Column column = super.readColumn(metaData, values);
+
+		if (column.getDefaultValue() != null)
+		{
+			// Oracle pads the default value with spaces
+			column.setDefaultValue(column.getDefaultValue().trim());
+		}
+		if (column.getTypeCode() == Types.DECIMAL)
+		{
+			// We're back-mapping the NUMBER columns returned by Oracle
+			// Note that the JDBC driver returns DECIMAL for these NUMBER columns
+			switch (column.getSizeAsInt())
+			{
+				case 1:
+					if (column.getScale() == 0)
+					{
+						column.setTypeCode(Types.BIT);
+					}
+					break;
+				case 3:
+					if (column.getScale() == 0)
+					{
+						column.setTypeCode(Types.TINYINT);
+					}
+					break;
+				case 5:
+					if (column.getScale() == 0)
+					{
+						column.setTypeCode(Types.SMALLINT);
+					}
+					break;
+				case 18:
+					column.setTypeCode(Types.REAL);
+					break;
+				case 22:
+					if (column.getScale() == 0)
+					{
+						column.setTypeCode(Types.INTEGER);
+					}
+					break;
+				case 38:
+					if (column.getScale() == 0)
+					{
+						column.setTypeCode(Types.BIGINT);
+					}
+					else
+					{
+						column.setTypeCode(Types.DOUBLE);
+					}
+					break;
+			}
+		}
+		else if (column.getTypeCode() == Types.FLOAT)
+		{
+			// Same for REAL, FLOAT, DOUBLE PRECISION, which all back-map to FLOAT but with
+			// different sizes (63 for REAL, 126 for FLOAT/DOUBLE PRECISION)
+			switch (column.getSizeAsInt())
+			{
+				case 63:
+					column.setTypeCode(Types.REAL);
+					break;
+				case 126:
+					column.setTypeCode(Types.DOUBLE);
+					break;
+			}
+		}
+		else if ((column.getTypeCode() == Types.DATE) || (column.getTypeCode() == Types.TIMESTAMP))
+		{
+			// Oracle has only one DATE/TIME type, so we can't know which it is and thus map
+			// it back to TIMESTAMP
+			column.setTypeCode(Types.TIMESTAMP);
+
+			// we also reverse the ISO-format adaptation, and adjust the default value to timestamp
+			if (column.getDefaultValue() != null)
+			{
+				PatternMatcher matcher   = new Perl5Matcher();
+				Timestamp      timestamp = null;
+	
+				if (matcher.matches(column.getDefaultValue(), _oracleIsoTimestampPattern))
+				{
+					String timestampVal = matcher.getMatch().group(1);
+
+					timestamp = Timestamp.valueOf(timestampVal);
+				}
+				else if (matcher.matches(column.getDefaultValue(), _oracleIsoDatePattern))
+				{
+					String dateVal = matcher.getMatch().group(1);
+
+					timestamp = new Timestamp(Date.valueOf(dateVal).getTime());
+				}
+				else if (matcher.matches(column.getDefaultValue(), _oracleIsoTimePattern))
+				{
+					String timeVal = matcher.getMatch().group(1);
+
+					timestamp = new Timestamp(Time.valueOf(timeVal).getTime());
+				}
+				if (timestamp != null)
+				{
+					column.setDefaultValue(timestamp.toString());
+				}
+			}
+		}
+		return column;
+	}
+
+	/**
+     * {@inheritDoc}
+     */
+	protected Collection readIndices(DatabaseMetaDataWrapper metaData, String tableName) throws
SQLException
+	{
+		// Oracle has a bug in the DatabaseMetaData#getIndexInfo method which fails when
+		// delimited identifiers are being used
+		// Therefore, we're rather accessing the user_indexes table which contains the same info
+		// This also allows us to simply filter system-generated indices (which have GENERATED='Y'
+		// in the query result)
+
+		StringBuffer query = new StringBuffer();
+
+		query.append("SELECT a.INDEX_NAME, a.INDEX_TYPE, a.UNIQUENESS, b.COLUMN_NAME, b.COLUMN_POSITION
FROM USER_INDEXES a, USER_IND_COLUMNS b WHERE ");
+		query.append("a.TABLE_NAME=? AND a.GENERATED=? AND a.TABLE_TYPE=? AND a.TABLE_NAME=b.TABLE_NAME
AND a.INDEX_NAME=b.INDEX_NAME");
+		if (metaData.getSchemaPattern() != null)
+		{
+			query.append(" AND a.TABLE_OWNER LIKE ?");
+		}
+
+        Map               indices = new ListOrderedMap();
+		PreparedStatement stmt    = null;
+
+        try
+        {
+    		stmt = getConnection().prepareStatement(query.toString());
+    		stmt.setString(1, getPlatformInfo().isUseDelimitedIdentifiers() ? tableName : tableName.toUpperCase());
+    		stmt.setString(2, "N");
+    		stmt.setString(3, "TABLE");
+    		if (metaData.getSchemaPattern() != null)
+    		{
+    			stmt.setString(4, metaData.getSchemaPattern().toUpperCase());
+    		}
+
+    		ResultSet rs     = stmt.executeQuery();
+        	Map       values = new HashMap();
+
+        	while (rs.next())
+        	{
+        		values.put("INDEX_NAME",       rs.getString(1));
+        		values.put("INDEX_TYPE",       new Short(DatabaseMetaData.tableIndexOther));
+        		values.put("NON_UNIQUE",       "UNIQUE".equalsIgnoreCase(rs.getString(3)) ? Boolean.FALSE
: Boolean.TRUE);
+        		values.put("COLUMN_NAME",      rs.getString(4));
+        		values.put("ORDINAL_POSITION", new Short(rs.getShort(5)));
+
+        		readIndex(metaData, values, indices);
+        	}
+        }
+        finally
+        {
+            if (stmt != null)
+            {
+                stmt.close();
+            }
+        }
+		return indices.values();
+	}
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Platform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Platform.java?rev=373388&r1=373387&r2=373388&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Platform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Platform.java Sun
Jan 29 15:12:12 2006
@@ -23,6 +23,9 @@
 
 /**
  * The platform for Oracle 8.
+ * 
+ * TODO: We might support the {@link org.apache.ddlutils.Platform#createDatabase(String,
String, String, String, String, Map)}
+ *       functionality via "CREATE SCHEMA"/"CREATE USER" or "CREATE TABLESPACE" ?
  *
  * @author James Strachan
  * @author Thomas Dudziak
@@ -56,38 +59,43 @@
         info.setForeignKeysEmbedded(false);
         info.setIndicesEmbedded(false);
 
-        info.addNativeTypeMapping(Types.ARRAY,         "BLOB");
-        info.addNativeTypeMapping(Types.BIGINT,        "NUMBER(38,0)");
-        info.addNativeTypeMapping(Types.BINARY,        "RAW");
-        info.addNativeTypeMapping(Types.BIT,           "NUMBER(1,0)");
+        // Note that the back-mappings are partially done by the model reader, not the driver
+        info.addNativeTypeMapping(Types.ARRAY,         "BLOB",             Types.BLOB);
+        info.addNativeTypeMapping(Types.BIGINT,        "NUMBER(38)");
+        info.addNativeTypeMapping(Types.BINARY,        "RAW",              Types.VARBINARY);
+        info.addNativeTypeMapping(Types.BIT,           "NUMBER(1)");
+        info.addNativeTypeMapping(Types.DATE,          "DATE",             Types.TIMESTAMP);
         info.addNativeTypeMapping(Types.DECIMAL,       "NUMBER");
-        info.addNativeTypeMapping(Types.DISTINCT,      "BLOB");
-        info.addNativeTypeMapping(Types.DOUBLE,        "NUMBER(38)");
-        info.addNativeTypeMapping(Types.FLOAT,         "NUMBER(38)");
-        info.addNativeTypeMapping(Types.INTEGER,       "NUMBER(20,0)");
-        info.addNativeTypeMapping(Types.JAVA_OBJECT,   "BLOB");
-        info.addNativeTypeMapping(Types.LONGVARBINARY, "BLOB");
-        info.addNativeTypeMapping(Types.LONGVARCHAR,   "CLOB");
-        info.addNativeTypeMapping(Types.NULL,          "BLOB");
-        info.addNativeTypeMapping(Types.NUMERIC,       "NUMBER");
-        info.addNativeTypeMapping(Types.OTHER,         "BLOB");
-        info.addNativeTypeMapping(Types.REAL,          "NUMBER(18)");
-        info.addNativeTypeMapping(Types.REF,           "BLOB");
-        info.addNativeTypeMapping(Types.SMALLINT,      "NUMBER(5,0)");
-        info.addNativeTypeMapping(Types.STRUCT,        "BLOB");
-        info.addNativeTypeMapping(Types.TIME,          "DATE");
+        info.addNativeTypeMapping(Types.DISTINCT,      "BLOB",             Types.BLOB);
+        info.addNativeTypeMapping(Types.DOUBLE,        "DOUBLE PRECISION");
+        info.addNativeTypeMapping(Types.FLOAT,         "FLOAT",            Types.DOUBLE);
+        info.addNativeTypeMapping(Types.INTEGER,       "INTEGER");
+        info.addNativeTypeMapping(Types.JAVA_OBJECT,   "BLOB",             Types.BLOB);
+        info.addNativeTypeMapping(Types.LONGVARBINARY, "BLOB",             Types.BLOB);
+        info.addNativeTypeMapping(Types.LONGVARCHAR,   "CLOB",             Types.CLOB);
+        info.addNativeTypeMapping(Types.NULL,          "BLOB",             Types.BLOB);
+        info.addNativeTypeMapping(Types.NUMERIC,       "NUMBER",           Types.DECIMAL);
+        info.addNativeTypeMapping(Types.OTHER,         "BLOB",             Types.BLOB);
+        info.addNativeTypeMapping(Types.REAL,          "REAL");
+        info.addNativeTypeMapping(Types.REF,           "BLOB",             Types.BLOB);
+        info.addNativeTypeMapping(Types.SMALLINT,      "NUMBER(5)");
+        info.addNativeTypeMapping(Types.STRUCT,        "BLOB",             Types.BLOB);
+        info.addNativeTypeMapping(Types.TIME,          "DATE",             Types.TIMESTAMP);
         info.addNativeTypeMapping(Types.TIMESTAMP,     "DATE");
-        info.addNativeTypeMapping(Types.TINYINT,       "NUMBER(3,0)");
+        info.addNativeTypeMapping(Types.TINYINT,       "NUMBER(3)");
         info.addNativeTypeMapping(Types.VARBINARY,     "RAW");
         info.addNativeTypeMapping(Types.VARCHAR,       "VARCHAR2");
-        info.addNativeTypeMapping("BOOLEAN",  "NUMBER(1,0)");
-        info.addNativeTypeMapping("DATALINK", "BLOB");
 
-        info.addDefaultSize(Types.BINARY,  254);
-        info.addDefaultSize(Types.VARCHAR, 254);
+        info.addNativeTypeMapping("BOOLEAN",  "NUMBER(1,0)", "BIT");
+        info.addNativeTypeMapping("DATALINK", "BLOB",        "BLOB");
 
-        setSqlBuilder(new OracleBuilder(info));
-        setModelReader(new OracleModelReader(info));
+        info.addDefaultSize(Types.CHAR,       254);
+        info.addDefaultSize(Types.VARCHAR,    254);
+        info.addDefaultSize(Types.BINARY,     254);
+        info.addDefaultSize(Types.VARBINARY,  254);
+
+        setSqlBuilder(new Oracle8Builder(info));
+        setModelReader(new Oracle8ModelReader(info));
     }
 
     /**

Modified: db/ddlutils/trunk/src/test/jdbc.properties.oracle9
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/jdbc.properties.oracle9?rev=373388&r1=373387&r2=373388&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/jdbc.properties.oracle9 (original)
+++ db/ddlutils/trunk/src/test/jdbc.properties.oracle9 Sun Jan 29 15:12:12 2006
@@ -14,3 +14,7 @@
 datasource.url=jdbc:oracle:thin:@localhost:1521:ddlutilstest
 datasource.username=ddlutils
 datasource.password=ddlutils
+
+# For oracle, we should limit the schema to the one of the user
+# Note that Oracle requires this to be uppercase, even when using delimited identifiers
+ddlutils.schema=DDLUTILS



Mime
View raw message