Solved

jdbc database connection to the sql server is created with dynamic ports

Posted on 2014-03-20
2
252 Views
Last Modified: 2014-03-22
hi,

Need to create jdbc connection to sql server 2008,The problem is the port is dynamic.
is there any way in which database connection to the server is created with dynamic ports or in simple words without providing the port no.

ex.
Driver = com.microsoft.sqlserver.jdbc.SQLServerDriver
URL =jdbc:sqlserver://localhost:XXXXXXXXX;DatabaseName=test;

XXXX -> This can be any port i.e 1433,1435 etc
0
Comment
Question by:Rocking
2 Comments
 
LVL 26

Expert Comment

by:dpearson
ID: 39943214
If the port is dynamic, I think you either need a way to pass that value to the Java client (so it can be entered in the connection string) or you'd need to use some port mapping logic (e.g. in a firewall) to handle the routing.

If you went with the port mapping approach, then the client would always connect to a fixed port number, but the router would map that to the dynamic port.  But doing that would require a pretty skilled network guy to set that up.

Doug
0
 
LVL 24

Accepted Solution

by:
Tomas Helgi Johannsson earned 500 total points
ID: 39943973
Hi!

If you allow named connections you can connect to the instance using
jdbc:sqlserver://localhost;instanceName=instance1;integratedSecurity=true;<more properties as required>;

see here for more info

http://technet.microsoft.com/en-us/library/ms378428.aspx

Regards,
    Tomas Helgi
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL Help joining two tables 7 34
GUI builder for Eclipse? 8 13
SQL Help - 12 42
Minus first query 1 0
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now