Postgresql + sql server

Good morning,
I have to change in servoy.properties file the connection string for accessing SQL Server.
The cow was

jdbc:sqlserver://SQLSERVER:1433;DatabaseName=DATABASENAME;SelectMethod=cursor 

while the
new one is

jdbc:sqlserver://SQLSERVER\INSTANCE:1433;DatabaseName=DATABASENAME;SelectMethod=cursor 

With this SQLSERVER\INSTANCE syntax the connection string becomes

jdbc:sqlserver://SQLSERVERISTANCE:1433;DatabaseName=DATABASENAME;SelectMethod=cursor 

and I get the error "ERROR: NOT ONLINE. See log for details."
What is the correct syntax?
Thank you

Copilot

Certainly! Let’s address the correct syntax for your SQL Server connection string.

The server/instance name syntax used in the connection string is consistent across all SQL Server connection strings. Here’s the format you should use:

jdbc:sqlserver://ServerName\\InstanceName;Database=myDataBase;User Id=myUsername;Password=myPassword;

Now, let’s break down the components:

  1. ServerName: Replace this with the actual name of your SQL Server.
  2. InstanceName: If your SQL Server instance has a named instance (like your example with SQLSERVER\INSTANCE), use the backslash (\\) to separate the server name and the instance name.
  3. Database: Specify the name of the database you want to connect to.
  4. User Id and Password: Provide the appropriate credentials for authentication.

In your case, the corrected connection string should be:

jdbc:sqlserver://SQLSERVER\\INSTANCE:1433;DatabaseName=DATABASENAME;SelectMethod=cursor

Make sure to replace SQLSERVER, INSTANCE, and DATABASENAME with the actual values relevant to your setup. If you encounter any issues, double-check the server name, instance name, and database name.

Remember that the default SQL Server port is 1433, so there’s no need to explicitly specify it unless . If you continue to face the “ERROR: NOT ONLINE” issue, check your server’s availability and ensure that the necessary services are running.

Feel free to adjust the connection string according to your specific environment, and I hope this helps resolve the issue! :rocket:

You solved my problem.
Many thanks

1 Like