Expand my Community achievements bar.

SOLVED

Issue while creating a MSSql jdbc connection

Avatar

Level 2

Hi,

 

I am trying to create Adaptive form to submit data to MS SQL database. I have created a Datasource to create FDM and connect to database, but I am getting error while connecting to database.

 

I have installed : mssql-jdbc-11.2.0.jre8.jar and org.osgi.service.jdbc-1.0.0.jar

JDBC driver class : com.microsoft.sqlserver.jdbc.SQLServerDriver

JDBC connection URI : jdbc:sqlserver://localhost:1433;databaseName=myDatabase

 

both jars are Active, but I am not able to connect to database

 

Exception I am getting : 

 

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. 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.".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:191) [TestSql:1.0.0]
at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:242) [TestSql:1.0.0]
at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2280) [TestSql:1.0.0]
at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:493) [TestSql:1.0.0]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1388) [TestSql:1.0.0]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1069) [TestSql:1.0.0]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:905) [TestSql:1.0.0]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:452) [TestSql:1.0.0]
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1014) [TestSql:1.0.0]
at org.apache.sling.datasource.internal.DriverDataSource.getConnection(DriverDataSource.java:85) [org.apache.sling.datasource:1.0.4]
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDataSource(PooledConnection.java:224) [org.apache.sling.datasource:1.0.4]
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:180) [org.apache.sling.datasource:1.0.4]
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:730) [org.apache.sling.datasource:1.0.4]
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:664) [org.apache.sling.datasource:1.0.4]
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:482) [org.apache.sling.datasource:1.0.4]
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:156) [org.apache.sling.datasource:1.0.4]
at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:116) [org.apache.sling.datasource:1.0.4]
at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:103) [org.apache.sling.datasource:1.0.4]
at org.apache.sling.datasource.internal.DataSourceFactory$LazyJmxRegisteringDataSource.createPool(DataSourceFactory.java:364) [org.apache.sling.datasource:1.0.4]
at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:127) [org.apache.sling.datasource:1.0.4]
at org.apache.metamodel.jdbc.JdbcDataContext.getConnection(JdbcDataContext.java:614) [aem-dermis-core:3.0.156]
... 161 common frames omitted

 

 

I Don't know what I am missing here. 

 

Thanks in advance.

 

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

@rakesh443 

Error msg[0] points to an issue with a connection, so ensure the DB port is open if the DB is installed on the same machine or the DB machine is accessible otherwise.

I assume you're trying to connect a service from the model created to check if you're getting the output from the DB.

Usually, it boils down to an issue with firewall restriction on the port, so you may have to enable the firewall settings.

 

[0] - Connection refused: connect. 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.

View solution in original post

2 Replies

Avatar

Correct answer by
Employee Advisor

@rakesh443 

Error msg[0] points to an issue with a connection, so ensure the DB port is open if the DB is installed on the same machine or the DB machine is accessible otherwise.

I assume you're trying to connect a service from the model created to check if you're getting the output from the DB.

Usually, it boils down to an issue with firewall restriction on the port, so you may have to enable the firewall settings.

 

[0] - Connection refused: connect. 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.

Avatar

Employee Advisor

@rakesh443 Typically means the JDBC setting that you put in are unable to connect to the DB.

 

can be related to the hostname or IP. 

 

Is your DB running locally?