ANT: Jdbc driver error

2019-09-16 13:05发布

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.

标签: ant
4条回答
不美不萌又怎样
2楼-- · 2019-09-16 13:52

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>
查看更多
Rolldiameter
3楼-- · 2019-09-16 13:55

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楼-- · 2019-09-16 14:01
    <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>
查看更多
Viruses.
5楼-- · 2019-09-16 14:03

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.

查看更多
登录 后发表回答