Implementing failover in jConnect  Wide table support for Adaptive Server version 12.5 and later

Chapter 2: Programming Information

Performing server-to-server remote procedure calls

A Transact-SQL language command or stored procedure running on one server can execute a stored procedure located on another server. The server to which an application has connected logs in to the remote server, and executes a server-to-server remote procedure call.

An application can specify a “universal” password for server-to-server communication; that is, a password used in all server-to-server connections. Once the connection is open, the server uses this password to log in to any remote server. By default, jConnect uses the current connection’s password as the default password for server-to-server communications.

However, if the passwords are different on two servers for the same user and that user is performing server-to-server remote procedure calls, the application must explicitly define passwords for each server it plans to use.

jConnect versions 4.1 and later include a property that lets you set a universal “remote” password or different passwords on several servers. jConnect lets you set and configure the property using the setRemotePassword( ) method in the SybDriver class:

Properties connectionProps = new Properties();

public final void setRemotePassword(String serverName, 
    String password, Properties connectionProps

To use this method, the application needs to import the SybDriver class, then call the method:

import com.sybase.jdbcx.SybDriver;
SybDriver sybDriver = (SybDriver)
    Class.forName("com.sybase.jdbc2.jdbc.SybDriver").newInstance();
sybDriver.setRemotePassword
    (serverName, password, connectionProps);

NoteTo set different remote passwords for various servers, repeat the preceding call (appropriate for your version of jConnect) for each server.

This call adds the given server name-password pair to the given Properties object, which can be passed by the application to DriverManager in DriverManager.getConnection (server_url, props).

If serverName is NULL, the universal password will be set to password for subsequent connections to all servers except the ones specifically defined by previous calls to setRemotePassword( ).

When an application sets the REMOTEPWD property, jConnect no longer sets the default universal password.





Copyright © 2003. Sybase Inc. All rights reserved. Wide table support for Adaptive Server version 12.5 and later

View this book as PDF