Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

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

asked 20 Aug '13, 06:34

giri's gravatar image

giri
46116
accept rate: 0%

edited 21 Aug '13, 02:22

Volker%20Barth's gravatar image

Volker Barth
40.2k361549822


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.

permanent link

answered 20 Aug '13, 13:25

Karim%20Khamis's gravatar image

Karim Khamis
5.7k53870
accept rate: 40%

edited 21 Aug '13, 02:19

Volker%20Barth's gravatar image

Volker Barth
40.2k361549822

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.

permanent link

answered 20 Aug '13, 10:24

Chris%20Keating's gravatar image

Chris Keating
7.8k49128
accept rate: 32%

Thanks a lot Chris and Karim. I'll configure interface file and try connecting to individual databases using Open Client Interface. I'll update the outcome.

Thanks Girish

(21 Aug '13, 01:39) giri
1

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.

(21 Aug '13, 06:54) giri
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×438
×4

question asked: 20 Aug '13, 06:34

question was seen: 2,435 times

last updated: 22 Aug '13, 14:07