java - 在 Oracle 11.1.0 中使用 DdlUtils 时出现问题

标签 java ant oracle11g ddlutils

这个问题类似于问题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 中找不到相应的类型。

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

最佳答案

很晚了,5年后,
无论如何思考,对 future 的帮助很少。

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

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


问题:DdlUtils 中的 TypeMapping 是通过 exisitinf java.sql.Types 枚举完成的。然而,对于 Oracle11g,有一些额外的类型。因此提出了问题。 希望对您有所帮助。

关于java - 在 Oracle 11.1.0 中使用 DdlUtils 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5714338/

相关文章:

Java旋转图像变成全黑?

java - 如何为获取文件和值参数的本地应用程序创建 docker 镜像

ant - 将命令行参数传递给在 exec 中使用它们的目标

ANT:执行命令

java - Chronicle 与 Chronicle-queue 包

java - 如何将 antdirset 与 Ear 任务一起使用?

oracle - 创建每 5 分钟刷新一次的物化 View

sql - 将 Oracle 查询转换为 SQL Server Reporting Services (SSRS) 的存储过程

oracle11g - 如何像SQL2005数据库一样备份和还原ORACLE数据库11g

java - com.google.auth.oauth2.GoogleCredentials.createScoped 处出现 StackOverflowError(GoogleCredentials.java :222)