Setting connection properties  URL connection property parameters

Chapter 2: Programming Information

Connecting to Adaptive Server

In your Java application, define a URL using the jConnect driver to connect to an Adaptive Server. The basic format of the URL is:

jdbc:sybase:Tds:host:port

where:

jdbc:sybase identifies the driver.

Tds is the Sybase communication protocol for Adaptive Server.

host:port is the Adaptive Server host name and listening port. See $SYBASE/interfaces (UNIX) or %SYBASE%\ini\sql.ini (Windows) for the entry that your database or Open Server application uses. Obtain the host:port from the “query” entry.

You can connect to a specific database using this format:

jdbc:sybase:Tds:host:port/database 

NoteTo connect to a specific database using Adaptive Server Anywhere 6.x and later or DirectConnect, use the SERVICENAME connection property to specify the database name instead of “/database.”

Example

The following code creates a connection to an Adaptive Server on host “myserver” listening on port 3697:

SysProps.put("user","userid");
SysProps.put("password","user_password");
String url = "jdbc:sybase:Tds:myserver:3697";
Connection_con =
   DriverManager.getConnection(url,SysProps);




Copyright © 2003. Sybase Inc. All rights reserved. URL connection property parameters

View this book as PDF