ANT: Jdbc driver error

荒凉一梦 提交于 2019-12-12 01:35:03

问题


Trying the below code:

 <sql
    classpath="postgresql-8.4-701.jdbc3.jar"
    driver="org.database.jdbcDriver"
    url="devtest"
    userid="uid"
    password="pass">

select * from tab where tname = 'GR_DOCUMENT_PRINT_DFV';

 </sql>

Getting the below error:

BUILD FAILED
C:\Program Files\Java\apache-ant-1.8.1\build.xml:62: Class Not Found: JDBC driver
org.database.jdbcDriver could not be loaded

Total time: 1 second

Please help.

Now I have updated the code. Add classpath to the previous code. Also add mysql-connector-java-3.0.8-stable-bin.jar and postgresql-8.4-701.jdbc3.jar file to ANT_HOME/lib but still getting the same error.


回答1:


If you're using Oracle, can you try

<path id="antclasspath"> 
    <fileset dir="path-to-lib"> 
        <include name="ojdbc14.jar"/> 
    </fileset> 
</path> 


<sql 
    driver="oracle.jdbc.driver.OracleDriver" 
    url="jdbc:oracle:thin:@serverip:1521:sid" 
    userid="userid" 
    password="password" 
    print="yes" 
    classpathref="antclasspath"> 
    select * from tab where tname = 'GR_DOCUMENT_PRINT_DFV'; 
</sql> 

If you still have the same error, run ant with the -v switch. That will direct the sql task to print out the classpath it's using and you can verify.




回答2:


You should specify class path to your driver

<sql classpathref="${classpath.id}" driver="" ...

And define your class path

<path id="classpath.id">
        <fileset file="..." />
</path>



回答3:


does the jar containing org.database.jdbcDriver is in the classpath? you probably need to add a classpath attribute

<sql
classpath="mysql-connector-java-3.0.8-stable-bin.jar"
driver="org.database.jdbcDriver"
url="devtest"
userid="uid"
password="pass">



回答4:


    <sql
        driver="oracle.jdbc.driver.OracleDriver"
        url="jdbc:oracle:thin:@localhost:1521:ENOVIADEV"
        userid="sys"
        password="enoviaV6"
        expandProperties="true"
        classpathref="antclasspath">
        <connectionProperty name="internal_logon" value="SYSDBA"/>          
          <transaction>
            create tablespace ${TablespaceName} datafile '${DatafilePath}/${DatafileNAME}' size 5M REUSE AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
          </transaction>
          <transaction>
          create user ${oracle.dbuser} identified by ${oracle.dbpassword} default tablespace ${TablespaceName} temporary tablespace TEMP;
         </transaction>
         <transaction>
         grant connect, resource, unlimited tablespace to ${oracle.dbuser};
         </transaction>
         <transaction>
         alter user ${Username} default role all;
         </transaction>
    </sql>


来源:https://stackoverflow.com/questions/3210722/ant-jdbc-driver-error

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