I am connecting HANA DB via ngdbc.jar. Connection is made properly but after running query 3-4 times connection to HANA DB is lost. When I restart my JAVA server again it works for 3-4 times. Can anyone help?
Error Msg-
WARN [org.hibernate.util.JDBCExceptionReporter] (http--0.0.0.0-8080-6) SQL Error: -708, SQLState: 08006
ERROR [org.hibernate.util.JDBCExceptionReporter] (http--0.0.0.0-8080-6) Data receive failed [Connection reset].
INFO [com.ultimatix.controller.MetricsController] (http--0.0.0.0-8080-6) context setMonthFreezeDateorg.hibernate.exception.JDBCConnectionException: could not execute query
ERROR [org.hibernate.transaction.JDBCTransaction] (http--0.0.0.0-8080-6) JDBC rollback failed: com.sap.db.jdbc.exceptions.jdbc40.SQLNonTransientConnectionException: Connection to database server lost; check server and network status [System error: Socket closed]
I can see you are using Hibernate based on your log.
Can you elaborate a little bit on your stack?
As #RC said, you should consider connection pooling instead of opening direct connections if this is what you are doing in your "JAVA" server.
May be your are keeping the connection open for too long and it times out.
These are all guesses, until you can share any logs or sample code.
One more thing, related to the ngjdbc driver only, there is a "reconnect" connection property which by default is set to false.
Regards
Related
I'm stucked in a problem during connection from my java project (play framework ) to a sql server database in Azure.
In local enviroment the connection works fine.
Below parameter in my application.conf :
db.default {
url="jdbc:sqlserver://server-name.database.windows.net:1433;database=database-name"
encrypt=true
trustServerCertificate=false
hostNameInCertificate="*.database.windows.net"
loginTimeout=30
driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
username="root"
password="RootPwd"
}
This is the error received:
ERROR o.h.e.jdbc.spi.SqlExceptionHelper HikariPool-1 - Connection is
not available, request timed out after 30006ms. ERROR
o.h.e.jdbc.spi.SqlExceptionHelper The TCP/IP connection to the host
par-sql-server.database.windows.net, port 1433 has failed. Error:
"par-sql-server.database.windows.net. 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.". ERROR
p.api.http.DefaultHttpErrorHandler
play.api.PlayException: Execution exception[[CompletionException:
org.hibernate.exception.JDBCConnectionException: Unable to acquire
JDBC Connection]]
at play.api.http.HttpErrorHandlerExceptions$.$anonfun$convertToPlayException$3(HttpErrorHandler.scala:388)
at scala.Option.getOrElse(Option.scala:201)
at play.api.http.HttpErrorHandlerExceptions$.convertToPlayException(HttpErrorHandler.scala:388)
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:373)
at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:264)
at play.core.server.AkkaHttp
I have already checked that tcp/ip port 1433 is correctly available for database, and my ip is correctly setted to avoid firewall.
Any suggestions?
thanks
Usually this error occurs when the database is not getting the connection within the default connectionTimeout property.
You can try to increase the value of connectionTimeout in Java config as below:
config.setConnectionTimeout(300000);
below is one of the sample config:
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(20);
config.setConnectionTimeout(300000);
config.setConnectionTimeout(120000);
config.setLeakDetectionThreshold(300000);
If possible let me know the steps to reproduce this issue so that I can fix it accordingly, also based on the information you've provided these blogs (Blog1, Blog2) will help you in establishing the connection
I have an multithreaded spring application which interacts with database with a set of queries and gives the output. I recently encountered this error and not sure exactly what is its cause. As far as managing the connections on the server, I don't see any issues over there and till now everything was getting executed as expected and I haven't made any recent changes.
I see After some time things started working as expected, but now I'm curios about this error and the cause of it just to prevent this in future.
Posting the log trace as below, any help in decoding this will be highly appreciated.
SQL Error: 17002, SQLState: 08006
2021-03-11 13:46:28,508 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-59) IO Error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
2021-03-11 13:46:28,548 WARN [org.jboss.jca.adapters.jdbc.WrappedConnection] (default task-59) IJ030041: Error during closing a statement for: java:jboss/datasources/<pool-name>: java.sql.SQLRecoverableException: Closed Connection
at oracle.jdbc.driver.PhysicalConnection.needLine(PhysicalConnection.java:3247)
at oracle.jdbc.driver.OracleStatement.closeOrCache(OracleStatement.java:1392)
at oracle.jdbc.driver.OracleStatement.close(OracleStatement.java:1375)
at oracle.jdbc.driver.OracleStatementWrapper.close(OracleStatementWrapper.java:119)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.close(OraclePreparedStatementWrapper.java:96)
at org.jboss.jca.adapters.jdbc.WrappedStatement.internalClose(WrappedStatement.java:1491)
at org.jboss.jca.adapters.jdbc.WrappedConnection.returnConnection(WrappedConnection.java:286)
at org.jboss.jca.adapters.jdbc.WrappedConnection.close(WrappedConnection.java:256)
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.closeConnection(DatasourceConnectionProviderImpl.java:144)
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.releaseConnection(AbstractSessionImpl.java:391)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.releaseConnection(LogicalConnectionImpl.java:255)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.close(LogicalConnectionImpl.java:182)
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.close(JdbcCoordinatorImpl.java:205)
at org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl.close(TransactionCoordinatorImpl.java:297)
at org.hibernate.internal.SessionImpl.close(SessionImpl.java:369)
Hibernate tries to close a statement but the connection (session) has been closed/terminated for some reason:
Error during closing a statement for:
java:jboss/datasources/: java.sql.SQLRecoverableException:
Closed Connection
SQL Error: 17002, SQLState: 08006 IO Error: A connection attempt
failed because the connected party did not properly respond after a
period of time, or established connection failed because connected
host has failed to respond
There could be multiple reason why this happen. Maybe it was a network problem that caused a timeout.
You should check with your DBA if he can see any errors on the database server.
Do you have configured database connection validation for your JDBC datasource?
http://www.mastertheboss.com/jboss-server/jboss-datasource/how-to-automatically-reconnect-to-the-database-in-wildfly
There was a network connection blip between your app server & database server. But what caused it, we can't explain without any more details. If it started working automatically, then it looks like a temporary network issue between the two servers. Or it would have caused if you have used invalid ip/dns name in db server url. But that would require a change from your side to fix the issue.
I am facing this problem.
Stackstrace
2014-09-22 16:50:35,292 [main] WARN org.hibernate.cfg.SettingsFactory
- Could not obtain connection metadata org.apache.commons.dbcp.SQLNestedException: Cannot create
PoolableConnectionFactory (IO Error: Connection reset) at
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
at
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
can any one please let me know the cause of this , oracle version is 11g
Your stack trace specifies that you are unable to connect to your database.
Make sure that your database server is listening on the correct port (1521 default).
Check your firewall or any setting that prevents you from accessing your database server
Check your dataSource settings for any errors.
If your database is an external one, make sure that the listener.ora is configured correctly.
I am working in spring3 project. When I run my code sometimes i am getting this Jdbc Connection Exception for some particular functionality but other functionalities working very fine. And also this Exception is not occurring repetitively but sometimes, So I can't get where the mistake will be.
Please help me to come out of this problem.
<[weblogic.servlet.internal.WebAppServletContext#1b6e978 - appName: '_auto_generated_ear_', name: 'ae', context-path: '/ae'] Root cause of ServletException.
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Listener refused the connection with the following error:
ORA-12519, TNS:no appropriate service handler found
The Connection descriptor used by the client was:
localhost:1521:XE at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:573)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:637)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:666)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:674)
Truncated. see log file for complete stacktrace
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12519, TNS:no appropriate service handler found
The Connection descriptor used by the client was:
localhost:1521:XE
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:420)
at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:165)
Truncated. see log file for complete stacktrace
There are 2 common reason for that symptoms
The connection pool is exhausted, too many active connections open and the next client cannot get it. This might be a connection pool leak
The connection pool setting doesn't test idle connection periodically / on borrow, hence when TCP connection truncated by OS (eg: because the OS thinks it's idle doing nothing), the pool still thinks it's a valid
To resolve this issue, just Restart your MySQL service
How to restart the MySQL service
On Windows: https://www.mysqltutorial.org/mysql-adminsitration/restart-mysql
On Linux: https://linuxhint.com/restart-mysql-in-ubuntu/
After a SQL Server database restart, my Tomcat 6 Spring web applications receives an SQL exception on the first attempt to query the database. Note: Tomcat 6 has continued to run during the SQL Server restart and I'm using myBatis. The exception is as follows:
org.springframework.dao.DataAccessResourceFailureException:
Error querying database. Cause: java.sql.SQLException: I/O Error: Connection reset
Any subsequent queries execute fine (without exception). How can I prevent this exception on the first query?
Set up your pool to test connections before giving them to your application
use testOnBorrow=true and (for instance) validationQuery="select 1" in your db pool connection