DB Reconnect (AS Java) 
SAP NetWeaver AS Java can automatically handle database errors – for example, when the database crashes or the network connection to the database fails. For Open SQL and Native SQL the handling of DB connection errors works as follows (see also the graphic below):
The JDBC driver detects an error and throws an SQLException when database access fails.
AS Java classifies the error and propagates the exception to the caller.
The connection is only closed in the event of a fatal connection error, in which case the following steps occur.
AS Java checks all connections currently in the connection pool:
It immediately checks all idle connections and closes defective ones.
It checks used connections only on release and closes defective ones.
AS Java alerts all other AS Java instances that a failure has occurred. Each AS Java instance checks its connections by performing the previous step.
In the event of subsequent connection requests, AS Java tries to create new connections and populates the connection pool again.
After error classification, all calls using the broken connection receive a well defined connection already closed exception.
For Vendor SQL, the connection error handling is similar. The main difference is the deferred error classification that only takes place during commit, rollback, and close of the connection. Before error classification, all calls using the broken connection receive database-specific exceptions.

Handling of DB Connection Errors for AS Java
Recommendation
We recommend you to close SQL connections immediately when no longer required.