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


To connect to our database over a WIFI or VPN connection I need to specify a Port Number. This worked fine until I rebooted the server last night and the Port on which the database was listening has changed.

Is there a way I can specify a Port Number that should always be used?

We are running SQL Anywhere 9.0, no option to upgrade.

asked 14 Sep '16, 06:53

Jongee's gravatar image

accept rate: 0%

You can specify the port number the server should use with the PORT protocol option, such as

dbsrv9 -x tcpip(port=2638) -n MyServer...

or even specify a range of ports of which the server should use all those that are available:

dbsrv9 -x tcpip(port=2638,49152-49155) -n MyServer...

Likewise, the client can explicitly use a specified port (or a port range, of which then the first available is used) in the PORT protocol option of the LINKS connection parameters:

-c "...;LINKS=tcpip(host=<ServerIP>;port=2638,49152-49155);..."

For details, see that FAQ .

permanent link

answered 14 Sep '16, 07:13

Volker%20Barth's gravatar image

Volker Barth
accept rate: 34%

edited 14 Sep '16, 07:18

Thanks, Is there a way of seeing the current port range that has been specified?

(14 Sep '16, 07:19) Jongee
Replies hidden

Hm, that could be visible in the server's and/or client's communication logs, i.e. dbsrv9 -z resp. the LOG= client connection parameter.

You can also query the server's command line resp. used TCP/IP addresses (including ports):

SELECT property('CommandLine'), property('TcpipAddresses');

but the latter will not tell whether they have been explicitly specified or not (unless they differ from the default ports, i.e. 2638 and then 49152 and up...).

Sorry, property('TcpipAddresses') will not work for you, it has been introduced with v11.

(14 Sep '16, 08:13) Volker Barth

> seeing the current port range

SELECT PROPERTY ( 'CommandLine' );

'-c 100M -o dbeng9_log_ddd9.txt -os 10M -x tcpip(port=12345,12350-12359) -zl -zp -zt ddd9.db -hn0,7568:192 '
(14 Sep '16, 09:43) Breck Carter

Can I ask how I run this?

It might seem like a simple question, but I have very limited knowledge in this area.

(14 Sep '16, 10:35) Jongee

Just start Interactive SQL (either on the box with the database server or on your client machine) and execute the SQL query there...

(14 Sep '16, 11:13) Volker Barth

In addition to what Volker said:

The SELECT statement I posted is shorthand for the following query:

SELECT PROPERTY ( 'CommandLine' ) FROM dummy;

If you are familiar with Oracle, for example, dummy is like dual.

You can run the query from any application that connects to SQL Anywhere via ODBC. It returns a singleton result set; i.e., a single column in a single row. The column data type is varchar(32000).

For example, in PowerBuilder you can code this:

SELECT PROPERTY ( 'CommandLine' )
  INTO :ls_commandline
  FROM dummy

In this particular case, it is up to your application to parse the return value; e.g., to find and understand the port values 12345,12350-12359 that are embedded in the command line.

The PROPERTY function is a builtin SQL Anywhere function that returns the current value of a specific server-level property.

The CommandLine property is the string of options that followed the "dbsrv9" program name on the Windows command line, plus some extra "magic" stuff that SQL Anywhere adds (-hn0,7568:192) which you can ignore.

(16 Sep '16, 07:29) Breck Carter
showing 1 of 6 show all flat view

You could try running the dblocate utility (dblocate ip-address).

Example: dblocate

However, I must confess that version 9 of this tool crashed on me (version 9 is very ancient software).

permanent link

answered 15 Sep '16, 10:55

JBSchueler's gravatar image

accept rate: 20%

Thanks for the response. I will give this a try.

Reference version 9, it is a third party piece of software so I have no option to update. I know the supplier has just released an alternative system that runs on a new cloud based platform so maybe this is why we are stuck on v9.

(15 Sep '16, 10:58) Jongee
Your answer
toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 14 Sep '16, 06:53

question was seen: 3,548 times

last updated: 16 Sep '16, 07:29