cancel
Showing results for 
Search instead for 
Did you mean: 

JDBC Connection to SQLAnywhere 11.0.1

Former Member
0 Kudos

I'm working on extracting information from a SQLAnywhere 11.0.1 database to migrate them to a more recent solution.

However, I'm running into problems getting a JDBC connection to work.

I've found references to two different JDBC drivers.

  1. jconn
  2. sajdbc

However, I am not able to connect using the information from either of these.

I am connecting over a network. I can provide the host, server, database, username, and password. But I am unsure of the connection string format to do so.

And especially when attempting to use the jconn JDBC driver, I am getting an error of other, I assume to be dependent, files missing: "Error connecting to database: (using class com.sybase.jdbc3.jdbc.SybDriver)

no dbjdbc11 in java.library.path"

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

More information: It looks like my first attempt at including dbjdbc11.dll simply failed.
But I am getting a new error:

Error connecting to database: (using class com.sybase.jdbc3.jdbc.SybDriver)

JZ006: Caught IOException: java.net.ConnectException: Connection timed out: connect


Which I can only assume means I am building the connection string incorrectly.

former_member207653
Active Participant
yzzhang
Employee
Employee
0 Kudos

Hi,

If jConnect is used, should refer the following document

Setting the class path for jConnect

For your application to use jConnect, the jConnect classes must be in your class path at compile time and run time, so that the Java compiler and Java runtime can locate the necessary files.

The following command adds the jConnect 6.0.5 driver to an existing CLASSPATH environment variable (where path is your jConnect installation directory).

set classpath=path\jConnect-6_0\classes\jconn3.jar;%classpath%

Importing the jConnect classes

The classes in jConnect 6.0.5 are all in com.sybase.jdbc3.jdbc. You must import these classes at the beginning of each source file:

import com.sybase.jdbc3.jdbc.*

Specifying a database on a server

Each SQL Anywhere database server can have one or more databases loaded at a time. If the URL you supply when connecting via jConnect specifies a server, but does not specify a database, then the connection attempt is made to the default database on the server.

You can specify a particular database by providing an extended form of the URL in one of the following ways.

Using the ServiceName parameter

jdbc:sybase:Tds:host:port?ServiceName=database

The question mark followed by a series of assignments is a standard way of providing arguments to a URL. The case of ServiceName is not significant, and there must be no spaces around the = sign. The database parameter is the database name, not the server name. The database name must not include the path or file suffix. For example:

Connection con = DriverManager.getConnection(

      "jdbc:sybase:Tds:localhost:2638?ServiceName=demo", "DBA", "sql");

yzzhang
Employee
Employee
0 Kudos

Hi Tim,

I was wondering if you could try this:

Connection con = DriverManager.getConnection("jdbc:ianywhere:driver=SQL Anywhere 11;uid=dba;pwd=sql;eng=server_name;dbn=db_name;host=host_or_ipaddress:port" );

Best regards,