2

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?

Community
  • 1
  • 1
GLA
  • 953
  • 2
  • 9
  • 14
  • 1
    **additional information:** After debugging a little i found out that the error occurs when reading the column 'XML_CONTENT' with type 2007 in table 'WWV_MIG_FORMS' in Database 'unnamed'. Not being an expert with oracle i guess the ant job tries to read a system table. If this is true, this would indicate that writedatatofile ignores the schemapattern specified in the corresponding attribute. – GLA Apr 19 '11 at 13:44
  • 1
    **update:** I solved the issue with schemapattern. In org.apache.ddlutils.task.WriteDataToFileCommand#execute i added the model to the following call: getDataIO().writeDataToXML(getPlatform(), model, new FileOutputStream(_outputFile), _encoding); This patch is already included in the ddlutils repository. The general problem with type 2007 remains unresolved. – GLA Apr 19 '11 at 14:33

1 Answers1

0

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.

peaceUser
  • 457
  • 5
  • 19