Show TOC

Reconnecting to the DB in the Event of a DB CrashLocate this document in the navigation structure

Use

If the database you are working with crashes, you cannot use the open connections to the DB anymore. The AS Java provides different solutions for reconnecting to the database when you use Open, Native, or Vendor SQL .

Features

If you use either Open SQL or Native SQL, the methods for working with connections should throw java.sql.SQLException . Each exception has an ID that is parsed within the Open SQL/Native SQL framework. Some of the IDs signify that the database has crashed or the connection has been broken due to some other reason. In case of such exceptions, the DataSource you work with receives a javax.sql.ConnectionEventListener.connectionErrorOccurred() event. It closes the connections one by one and at reconnect to the DB provides new connections to the applications that work with it. The mechanism is the same if you use a JDBC 2.0 compliant driver.

AS Java does not support automatic reconnection for custom defined driver-based DataSources which use Vendor SQL engine type, that is, for JDBC 1.x DataSources.

Note

If you want to keep using Vendor SQL and reconnect to the database automatically, you have to create a DataSource based on the ConnectionPoolDataSource implementation provided by the JDBC driver (this is also known as JDBC 2.0 DataSource). Automatic reconnection is possible if the JDBC driver sends a javax.sql.ConnectionEventListener.connectionErrorOccured() event.

Recommendation

If the database you are working with is supported by SAP, we recommend that you use Native SQL instead of Vendor SQL.

For more information about the SAP-supported databases, refer to the SAP NetWeaver Product Availability Matrix (PAM) at http://service.sap.com/pam .