on 2013 Aug 20 7:34 AM
Hi all, I'm using Open Client API's to connect to the database server. Connection to the server using ct_connect is successful. But I have more than one database running for same database server. I'm not able find any connection property to set the database name to connect to (using ct_con_props function). Is there a way to specify the database name to connect to using ct_connect ?
Thanks
Girish
Request clarification before answering.
Chris' comment above is correct. Unlike ASE, SQL Anywhere does not have the concept of logging into a master database and then having the client send a USE statement to switch databases. Hence, SQL Anywhere needs to use the information available within the login packet to determine which database the client wants to connect to. The server therefore keys in on the service name which is in the login packet and uses that name as the database that the client wants to connect to. This service name information is only used in cases where the server is running multiple databases. For servers that are only running one SQL Anywhere database, the server assumes the client wants to connect to the single database that is running on the server regardless of what is specified as the service name in the login packet. Hence, if you are running multiple databases on the same SQL Anywhere server and need to connect using either Open Client or jConnect, then specify the name of the database that you need to connect to as the service name during the connect attempt and you should be good to go.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
IIRC you would require separate entries in the interfaces file for each of the databases configured on the SQLA server. You would then connect to the name defined in the interfaces file for the desired database to establish the connection.
For example,
dbsrvx.exe -n DbServerName -x tcpip sqla_db_1.db -n db1 sqla_db_2.db -n db2
The interfaces file would have entries similar to:
[db1] query=NLWNSCK,<ip>,<port> master=NLWNSCK,<ip>,<port>
[db2] query=NLWNSCK,<ip>,<port> master=NLWNSCK,,<ip>,<port>
where [db1] and [db2] are the database names hosted by the SQLA engine. Make sure that you specify the <ip> and <port> values to reflect the environment on which the server is configured.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Created a separate entry in interface file for each database running on SQL Anywhere server. Used 'database name'(service name) in place of 'server name' while initiating connection to server using ct_connect.Connection to the specified database was successful.
Thanks a lot for the detailed explanation and resolution to the problem.
User | Count |
---|---|
54 | |
6 | |
6 | |
5 | |
5 | |
5 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.