0

What should be the connection string for MSSQL Database in JAVA? Something like this.

enter image description here

Like someother things I want to know that Is there any password in connection string like password of my computer? what should be the port number, url etc? If you need more information about the connection let me know.

P.S. The black line has the servername.

My Connection values

datasource.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
datasource.url=jdbc:sqlserver://MSSQLSERVERFULL;databaseName=xproctor;
datasource.user=JUNAID-VAIO\Shamim
datasource.password=

ERROR: here is the ERROR I get while trying to connect database!!

Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (The TCP/IP connection to the host MSSQLSERVERFULL, port 1433 has failed. Error: "null. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".)

Sahan Serasinghe
  • 1,591
  • 20
  • 33
Junaid
  • 2,572
  • 6
  • 41
  • 77

2 Answers2

0

Use this connection string:

jdbc:sqlserver://;servername=server_name;integratedSecurity=true;authenticationScheme=JavaKerberos
roeygol
  • 4,908
  • 9
  • 51
  • 88
0

The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect". Enable Name pipes, TCP/IP, change Authentication mode, change localhost to 127.0.0.1 or ., add the Instance Name to the url, change the port, enable port and Apps in the firewall... almost everything. Its horrible! But the answer for your problem is: open SQL Server Configuration Manager -> Protocols for SQL SQLEXPRESS, select Properties of TCP/IP. In the tab IP Addresses, set the TCPPort in section IPAll to 1433.

Aamir M Meman
  • 1,645
  • 14
  • 15