Contents Index Supplying a URL for the server Database options set for jConnect connections

ASA Programming Guide
  JDBC Programming
    Using the jConnect JDBC driver
      Supplying a URL for the server

Specifying a database on a server

Each Adaptive Server Anywhere server may have one or more databases loaded at a time. The URL in the previous section specifies a server, but does not specify a database. 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:machine-name:port-number?ServiceName=DBN

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 DBN parameter is the database name.

Using the RemotePWD parameter 

A more general method allows you to provide additional connection parameters such as the database name, or a database file, using the RemotePWD field. You set RemotePWD as a Properties field using the setRemotePassword() method.

Here is sample code that illustrates how to use the field.

sybDrvr = (SybDriver)Class.forName(
    "com.sybase.jdbc2.jdbc.SybDriver" ).newInstance();
props = new Properties();
props.put( "User", "DBA" );
props.put( "Password", "SQL" );
sybDrvr.setRemotePassword(
   null, "dbf=asademo.db", props );
Connection con = DriverManager.getConnection(
   "jdbc:sybase:Tds:localhost", props );

Using the database file parameter DBF, you can start a database on a server using jConnect. By default, the database is started with autostop=YES. If you specify a DBF or DBN of utility_db, then the utility database will automatically be started.

For more information on the utility database, see Using the utility database.

For complete jConnect documentation, see http://sybooks.sybase.com/jc.html.


Contents Index Supplying a URL for the server Database options set for jConnect connections