Solved

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

Posted on 2014-03-20
2
284 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 27

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 25

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sql 2014,  lock limit 5 37
jboss 7.1 start up error 1 29
mysql jsp example issue 32 48
TSQL recursive CTE challenge... 8 29
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

808 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