This example shows how you display the operational state of a database in your Java application.
The individual steps are listed in the comments in the example.
Syntax
import com.sap.dbtech.powertoys.*; import com.sap.dbtech.rte.comm.RTEException; public class DBMDemo { public DBMDemo () { } public static void main(String[] args) { DBM session; try { // You connect to the DEMODB database. // See com.sap.dbtech.powertoys.DBM.dbDBM Method session = DBM.dbDBM(null, "DEMODB"); } catch (RTEException rteExc) { System.out.println ("connect failed: " + rteExc.toString ()); return; } try { // You log on as DBM operator OLEG with password MONDAY. // See com.sap.dbtech.powertoys.DBM.cmd Method session.cmd ("user_logon OLEG,MONDAY"); //You display the operational state of the database. String result = session.cmd ("db_state"); System.out.println(result); } catch (RTEException rteExc) { System.out.println ("connection broken: " + rteExc.toString ()); } catch (DBMException dbmExc) { System.out.println ("command failed: " + dbmExc.toString ()); } finally { try { // You then end the connection to the Database Manager program. // See com.sap.dbtech.powertoys.DBM.release Method session.release(); } catch (RTEException rteExc) { // ignore } } } }