SQL ANT 任务错误:找不到类:无法加载 JDBC 驱动程序 com.microsoft.sqlserver.jdbc.SQLServerDriver [英] SQL ANT TASK ERROR: Class Not Found: JDBC driver com.microsoft.sqlserver.jdbc.SQLServerDriver could not be loaded

查看:39
本文介绍了SQL ANT 任务错误:找不到类:无法加载 JDBC 驱动程序 com.microsoft.sqlserver.jdbc.SQLServerDriver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 ant 任务运行 SQL 查询,我使用的是 SQLServerDriver (sqljdbc.jar).此 jar 文件位于我拥有运行应用程序所需的所有 jar 的位置

I want to run an SQL query using the ant tasks, and I am using the SQLServerDriver (sqljdbc.jar). This jar file is located where I have all of my jars needed to run the application

(WebContent/WEB-INF/lib)

(WebContent/WEB-INF/lib)

这个目录是我在另一个任务命令中定义的类路径:

This directory is my classpath which I defined it in another TASK Command:

<!-- Define el classpath que es utilizado para compilar los archivos -->
<path id="classpath">
    <fileset dir="${libs.dir}">
        <include name="*.jar" />
    </fileset>
</path>

这个 jar 文件也在我的 ecplise 外部 jar 文件中指明.我试图运行的 ant 命令如下:

This jar file is also indicated in my ecplise external jar files. The ant command that I am trying to run is the following:

<target name="db.query" description="Ejecuta un query de SQL">
    <sql driver="${db.driverT}" url="${db.urlT}" userid="${db.userT}" 
            password="${db.passwordT}" print="TRUE">
        SELECT * FROM T007_EDO;
    </sql>
</target>

我应该怎么做来纠正我的错误?

What should I do to correct my error?

推荐答案

这个问题的答案是简单地将该行添加到我的 db.query 任务中.

The answer to this question was to simply add the line to my db.query task.

classpathref="classpath"

classpathref="classpath"

所以我有 jar 文件所在位置的类路径定义:

So I have my classpath deffinition of the place where the jar file is located in:

<path id="classpath">
<fileset dir="${libs.dir}">
    <include name="*.jar" />
</fileset>

我在我的蚂蚁任务中引用了它:

And I reference that in my ant task:

<target name="db.query" description="Ejecuta un query de SQL">
<sql driver="${db.driverT}" url="${db.urlT}" userid="${db.userT}" 
        password="${db.passwordT}" print="TRUE" classpathref="classpath">
    SELECT * FROM T007_EDO;
</sql>

这篇关于SQL ANT 任务错误:找不到类:无法加载 JDBC 驱动程序 com.microsoft.sqlserver.jdbc.SQLServerDriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆