0
votes

I build a Sybase-IQ 16.0 on red-hat 7 server.

I try to use dbisql for bulk load data in Sybase.

And I already successful by command in Sybase server:

dbisql -nogui -c "UID=DBA;PWD=sql;DWN=iqtry;host=172.16.50.137:2643;" -onerror continue READ /EXT_LOAD/Load_Test_Data.SQL

But I need to do this in java program from project requirement, so my program as below:

import java.io.*;
import java.sql.*;
import java.util.*;
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Test {
public static void main(String[] args) throws SQLException {

String dburl = "dbisql -nogui -c 'UID=DBA;PWD=sql;DWN=iqtry;host=172.16.50.137:2643;' -onerror continue READ /sybase/IQ_LOAD/load_DBA.atest.sql";

// Connect to Sybase Database
Connection con = DriverManager.getConnection(dburl);
Statement statement = con.createStatement();
}}

And I can compile in Syabse Server, but when I run this class, I got following error:

Exception in thread "main" java.sql.SQLException: No suitable driver found for

jdbc:sqlanywhere:uid=DBA;pwd=sql;eng=iqtry;database=atest;links=tcpip(host=172.

16.50.137,2643)

at java.sql.DriverManager.getConnection(DriverManager.java:689)

at java.sql.DriverManager.getConnection(DriverManager.java:270)

at Test.main(ConnectIQ.java:30)

From my problem, I have try to set classpath in my current path

set classpath = ./sybase/IQ-16_0/java/sajdbc4.jar

set classpath = ./sybase/IQ-16_0/java/jconn4.jar

But all is can't work.

1
You either don't have the right driver on your classpath, or the URL is wrong. Also note that depending on how the application is run, the environment variable CLASSPATH might not be used at all (that is actually the case for most ways Java applications are run). BTW Note that the code shown and the exception do not match (as the exception shows a different value for dburl than shown in your code).Mark Rotteveel

1 Answers

0
votes

The dbisql utility is a command line utility and should not be used in conjunction with Java. It is meant to be used through Shells like Bash, or, in a GUI environment.

sajdbc4.jar file is the JDBC driver for SAP IQ. As you've mentioned already about it being in the CLASSPATH, it is better to use its IQDataSource class which implements DataSource Interface from JDBC standard.

A simple code would be:

IQDataSource iqDataSource = new IQDataSource();
iqDataSource.setURL(jdbcUrl);
iqDataSource.setUser(username);
iqDataSource.setPassword(password);

Another hint: remember, each release of SAP IQ ties with a specific build of JDBC driver. Verify you are using the right version target for the right platform.

Hope this helps.