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".
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.