【问题标题】:Problem using DdlUtils with Oracle 11.1.0在 Oracle 11.1.0 中使用 DdlUtils 时出现问题
【发布时间】:2011-04-19 09:33:07
【问题描述】:

这个问题类似于问题https://stackoverflow.com/questions/3362965/problem-with-ddlutils-in-oracle-10g。由于我的问题(或至少我认为)与提到的问题略有不同,因此我发布了一个新问题。

我正在使用 DdlUtils-1.0、Java-6 (OpenJdk)、ojdbc6.jar 和 Oracle 11.1.0。迁移由 ant 任务启动。任务如下所示:

<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} 设置为“oracle10”,因为 ddlutils 不支持 oracle11。创建模式定义效果很好,但是在转储数据时,我遇到了以下异常:

[databaseToDdl] org.apache.ddlutils.model.ModelException:未知的 JDBC 类型代码 2007 [databaseToDdl] 在 org.apache.ddlutils.model.Column.setTypeCode(Column.java:215) [databaseToDdl] 在 org.apache.ddlutils.platform.JdbcModelReader.readColumn(JdbcModelReader.java:781) [databaseToDdl] 在 org.apache.ddlutils.platform.oracle.Oracle8ModelReader.readColumn(Oracle8ModelReader.java:117) [databaseToDdl] 在 org.apache.ddlutils.platform.JdbcModelReader.readColumns(JdbcModelReader.java:755) [databaseToDdl] 在 org.apache.ddlutils.platform.JdbcModelReader.readTable(JdbcModelReader.java:565) [databaseToDdl] 在 org.apache.ddlutils.platform.oracle.Oracle8ModelReader.readTable(Oracle8ModelReader.java:102) [databaseToDdl] 在 org.apache.ddlutils.platform.oracle.Oracle10ModelReader.readTable(Oracle10ModelReader.java:80) [databaseToDdl] 在 ...

http://download.oracle.com/javase/6/docs/api/constant-values.html#java.sql.Types.BIT 中列出了 jdbc 类型代码。显然 ddlutils 从 jdbc 驱动程序中获取了此类型代码,但在 java.sql.Types 中找不到相应的类型。

有人知道如何解决这个问题吗?

【问题讨论】:

  • 附加信息: 经过一番调试后,我发现在“未命名”数据库中的“WWV_MIG_FORMS”表中读取类型为 2007 的“XML_CONTENT”列时发生错误。我不是甲骨文专家,我猜蚂蚁工作试图读取系统表。如果为真,则表明 writedatatofile 忽略了相应属性中指定的模式模式。
  • 更新: 我用 schemapattern 解决了这个问题。在 org.apache.ddlutils.task.WriteDataToFileCommand#execute 中,我将模型添加到以下调用中:getDataIO().writeDataToXML(getPlatform(), model, new FileOutputStream(_outputFile), _encoding);此补丁已包含在 ddlutils 存储库中。 2007 型的一般问题仍未解决。

标签: java ant oracle11g ddlutils


【解决方案1】:

已经很晚了,5年后,
不过想一想,对未来的少数人可能会有帮助。

访问:org.apache.ddlutils.model.TypeMap
方法:getJdbcTypeName(int typeCode)
编写小逻辑,将 2007 设置为 12
即;

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


问题:TypeMapping in DdlUtils, is done with exisitinf java.sql.Types enum. Whereas, for the Oracle11g, the are few extra types. Hence issue raised. 希望对您有所帮助。

【讨论】:

    猜你喜欢
    • 2023-02-04
    • 1970-01-01
    • 1970-01-01
    • 2012-10-07
    • 1970-01-01
    • 1970-01-01
    • 2015-11-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多