Specifying a database on a server

Each Sybase IQ server may have one or more databases loaded at a time. The URL as described above 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=asiqdemo.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 information on the utility database, see “The utility database” and “Utility database server security”.