Problem using DdlUtils with Oracle 11.1.0

2.5k Views Asked by At

This question is similar to question https://stackoverflow.com/questions/3362965/problem-with-ddlutils-in-oracle-10g. Since my problem is (or at least i think it is) slightly different to the question mentioned, i post a new one.

I am using DdlUtils-1.0, Java-6 (OpenJdk), ojdbc6.jar and Oracle 11.1.0. The migration is started by ant tasks. The task looks like this:

<target name="dump-db" description="Dumps DB" depends="">
  <taskdef name="databaseToDdl" classname="org.apache.ddlutils.task.DatabaseToDdlTask">
    <classpath>
        <path refid="runtime-classpath"/>
        <path refid="project-classpath"/>
    </classpath>
</taskdef>
  <databaseToDdl modelname="${modelname}" verbosity="DEBUG" databasetype="${source.platform}" 
    usedelimitedsqlidentifiers="true" tabletypes="TABLE" schemapattern="${schemapattern}">      
    <database url="${source.url}"
            driverClassName="${source.driver}"
            username="${source.username}"
            password="${source.passwd}"
            initialsize="5"
            testonborrow="true"
            testonreturn="true"/>

    <writeschemasqltofile failonerror="false" outputfile="${out.dir}/${schema.file.sql}"/>
    <writedtdtofile outputfile="${out.dir}/${schema.file.dtd}"/>
    <writeSchemaToFile failonerror="false" outputFile="${out.dir}/${schema.file.xml}"/>
    <writedatatofile failonerror="false" outputfile="${out.dir}/${data.file.xml}" determineschema="true"/>
  </databaseToDdl>
</target>

${source.platform} is set to 'oracle10', since oracle11 is not supported by ddlutils. Creation of schema definitions works quite well, but when dumping the data i face the following exception:

[databaseToDdl] org.apache.ddlutils.model.ModelException: Unknown JDBC type code 2007 [databaseToDdl] at org.apache.ddlutils.model.Column.setTypeCode(Column.java:215) [databaseToDdl] at org.apache.ddlutils.platform.JdbcModelReader.readColumn(JdbcModelReader.java:781) [databaseToDdl] at org.apache.ddlutils.platform.oracle.Oracle8ModelReader.readColumn(Oracle8ModelReader.java:117) [databaseToDdl] at org.apache.ddlutils.platform.JdbcModelReader.readColumns(JdbcModelReader.java:755) [databaseToDdl] at org.apache.ddlutils.platform.JdbcModelReader.readTable(JdbcModelReader.java:565) [databaseToDdl] at org.apache.ddlutils.platform.oracle.Oracle8ModelReader.readTable(Oracle8ModelReader.java:102) [databaseToDdl] at org.apache.ddlutils.platform.oracle.Oracle10ModelReader.readTable(Oracle10ModelReader.java:80) [databaseToDdl] at ...

In http://download.oracle.com/javase/6/docs/api/constant-values.html#java.sql.Types.BIT the jdbc type codes are listed. Apparently ddlutils gets this type code from the jdbc driver but could not find a corresponding type in java.sql.Types.

Does anybody have an idea how to solve this?

1

There are 1 best solutions below

0
peaceUser On

It's very late, after 5 years,
However thought, can be helpful for few in in future.

Visit: org.apache.ddlutils.model.TypeMap
Method: getJdbcTypeName(int typeCode)
write small logic, to set 2007 to 12
ie;

if(typeCode == 2007){
typeCode = java.sql.Types.VARCHAR;
}


Issue: TypeMapping in DdlUtils, is done with exisitinf java.sql.Types enum. Whereas, for the Oracle11g, the are few extra types. Hence issue raised. Hope it helps.