shridhar
shridhar

Reputation: 79

Azure hybrid connection not connecting sql server database instance using java as backend code

I am tring create connection for sql server database using azure hybrid connection and my database server is sql server instance and it's name is something like this serverName/instance and my java code to connect the database server is similar to this

DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setUrl("jdbc:sqlserver://serverName/instance;database=database;user=userName;password=password;useSSL=false");

and aliasing works perfectly in local but when i deploy the code to azure it's telling can't able to connect to server "serverName".

Upvotes: 0

Views: 520

Answers (1)

Leon Yue
Leon Yue

Reputation: 16401

SQL Server connection string template:

String connectionUrl = "jdbc:sqlserver://<server>:<port>;databaseName=AdventureWorks;user=<user>;password=<password>";

You can change you code like this and replace your port number. For example:

DriverManagerDataSource dataSource = new DriverManagerDataSource();

dataSource.setUrl("jdbc:sqlserver://serverName/instance:1433;database=database;user=userName;password=password;useSSL=false");

Reference: Connection URL Sample.

Hope this helps.

Upvotes: 1

Related Questions