SQL ANT TASK ERROR: Class Not Found: JDBC driver com.microsoft.sqlserver.jdbc.SQLServerDriver could not be loaded

◇◆丶佛笑我妖孽 提交于 2019-12-12 02:47:00

问题


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)

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>

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?


回答1:


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

classpathref="classpath"

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>



来源:https://stackoverflow.com/questions/8734679/sql-ant-task-error-class-not-found-jdbc-driver-com-microsoft-sqlserver-jdbc-sq

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!