tags:

views:

37

answers:

3

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  A: 

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>
A: 

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">
Xavier Combelle
@Xavier - I have created a ODBC driver, also added classpath. But still ANT could not found the driver.
Shaun
+3  A: 

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.

JoseK
@JoseK - Thanks a lot this works fine.
Shaun