Ant:java.sql.SQLException:无法打开数据库文件

时间:2017-12-22 18:31:06

标签: ant sqlite

我尝试用Ant构建我的java项目。

Windows 7 Professional(64位),Java 1.8。

我运行自定义蚂蚁的目标:

ant create-dist-win-lite -Denvironment=development

此处 build.xml

<target name="create-dist-win-lite" description="Create WIN Lite dinstribute">
        <ac:var name="var.distribute.os.family" value="${prop.distribute.os.family.win}" />
        <ac:var name="var.distribute.version.type" value="${prop.distribute.version.lite}" />
        <ac:runtarget target="create-dist-os" />
</target>


    <target name="db:sqlite-exec-queries" depends="db:sqlite-set-variables,db:set-db-url">
        <echo message="var.data.dir.name=${var.data.dir.name}" />
        <echo message="var.db.driver=${var.db.driver}" />
        <echo message="var.db.current.url=${var.db.current.url}" />
        <echo message="var.db.lib.file.name=${var.db.lib.file.name}" />

        <delete dir="${var.data.dir.name}" />
        <mkdir dir="${var.data.dir.name}" />
        <sql driver="${var.db.driver}" url="${var.db.current.url}" userid="${var.db.user}" password="${var.db.pwd}" classpath="${lib.dir.name}/${var.db.lib.file.name}" delimiter="${var.db.delimiter}">
            <transaction src="${db.dir}/${var.db.type}/create-tables.sql" />
            <transaction src="${db.dir}/${var.db.type}/insert-data.sql" />
        </sql>
    </target>

结果,成功在 c:\ dev \ ca \ dist \ data \ ca.db 中创建了空的sqlite db文件。 但文件夹 c:\ dev \ ca \ dist \ data 仅为READ。

但目标不是成功完成。当执行目标 db:sqlite-exec-queries 时,我在此行中收到错误:

<sql driver="${var.db.driver}" url="${var.db.current.url}" userid="${var.db.user}" password="${var.db.pwd}" classpath="${lib.dir.name}/${var.db.lib.file.name}" delimiter="${var.db.delimiter}">

这里有完整的日志:

db:sqlite-exec-queries:
     [echo] var.data.dir.name=dist/data
     [echo] var.db.driver=org.sqlite.JDBC
     [echo] var.db.current.url=jdbc:sqlite://c:\dev\ca\dist\data/ca.db
     [echo] var.db.lib.file.name=sqlitejdbc-v056.jar
   [delete] Deleting directory c:\dev\ca\dist\data
    [mkdir] Created dir: c:\dev\ca\dist\data
      [sql] Executing resource: c:\dev\ca\db\sqlite\create-tables.sql
      [sql] Failed to execute:   CREATE UNIQUE INDEX [AccountStatuses_Index] ON [AccountStatuses]( [CODE]  ASC )

BUILD FAILED
c:\dev\ca\build.xml:1396: java.sql.SQLException: unable to open database file
        at org.sqlite.DB.execute(DB.java:275)
        at org.sqlite.Stmt.exec(Stmt.java:56)
        at org.sqlite.Stmt.execute(Stmt.java:83)
        at org.apache.tools.ant.taskdefs.SQLExec.execSQL(SQLExec.java:775)
        at org.apache.tools.ant.taskdefs.SQLExec.runStatements(SQLExec.java:745)
        at org.apache.tools.ant.taskdefs.SQLExec$Transaction.runTransaction(SQLExec.java:1055)
        at org.apache.tools.ant.taskdefs.SQLExec$Transaction.access$000(SQLExec.java:985)
        at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:653)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
        at net.sf.antcontrib.logic.RunTargetTask.execute(RunTargetTask.java:48)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)

0 个答案:

没有答案