cancel
Showing results for 
Search instead for 
Did you mean: 

How to check the connection between java and database in SAP?

Former Member
0 Kudos

Hi Experts,

I am the beginer in sap, could any one help to how to check the connection between java and oracle database in sap?

I need the command the command to check the connection .

regards

Ken

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

with the following code if you get SOP as

<b>Connection is : null</b>you have not achieved connection

Connection con=null;

try

{

Class.forName("oracle.jdbc.driver.OracleDriver");

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

con =DriverManager.getConnection("jdbc:oracle:thin:@<servername>:<portnumber>:DB","uname", "pwd");

System.out.println("Connection is : "+ con);

}

catch(SQLException sqe)

{

System.out.println("SQLException ............."+sqe);

}

catch(Exception ex)

{

System.out.println("GeneralException ............."+ex);

}

finally

{

try

{

conn.close(); // closing the connection

}

catch(Exception e)

{

System.out.println("Error");

}

}

<b>You can go through the following link for more details</b><a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/wiki?path=/pages/viewpage.action&pageid=47055">wiki</a>

Regards

Abhijith YS

SRudra
Contributor
0 Kudos

Ken,

Kindly post in more details, what yuou want to achieve.

If it is thru programming that u want to check if connection is alive, there is a method named disconnectIfAlive(), that acts on a model name.

regds,

Sukanta Rudra