jdbc - Run dbisql in Java Program -
i build sybase-iq 16.0 on red-hat 7 server.
i try use dbisql bulk load data in sybase.
and successful 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 need in java program project requirement, program 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 sybase database connection con = drivermanager.getconnection(dburl); statement statement = con.createstatement(); }}
and can compile in syabse server, when run class, got following error:
exception in thread "main" java.sql.sqlexception: no suitable driver found
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 problem, have try set classpath in current path
set classpath = ./sybase/iq-16_0/java/sajdbc4.jar
set classpath = ./sybase/iq-16_0/java/jconn4.jar
but can't work.
the dbisql
utility command line utility , should not used in conjunction java. meant used through shells bash, or, in gui environment.
sajdbc4.jar
file jdbc driver sap iq. you've mentioned being in classpath
, better use iqdatasource
class implements datasource interface jdbc standard.
a simple code be:
iqdatasource iqdatasource = new iqdatasource(); iqdatasource.seturl(jdbcurl); iqdatasource.setuser(username); iqdatasource.setpassword(password);
another hint: remember, each release of sap iq ties specific build of jdbc driver. verify using right version target right platform.
hope helps.
Comments
Post a Comment