Saturday, 20 June 2015

Test Database Connectivity from Weblogic Server to the Database

This post helps us to establish connectivity to the database from the Weblogic Server.

Go to MWHOME location

cd <WEBLOGIC HOME>/server/bin
set the environment
. ./setWLSEnv.sh

Run the below to test the connectivity.

java utils.dbping ORACLE_THIN <DB_USER_NAME> <DB_PASSWORD> <DB_HOST>:<DB_PORT>:<SID>

This will test the connection and display the results.

The result would be as below for a successful connection :

java utils.dbping ORACLE_THIN <DB_USER_NAME> <DB_PASSWORD> <DB_HOST>:<DB_PORT>:<SID>

**** Success!!! ****

You can connect to the database in your app using:

  java.util.Properties props = new java.util.Properties();
  props.put("user", "<DB_USER>");
  props.put("password", "<PASSWORD>");
  java.sql.Driver d =
    Class.forName("oracle.jdbc.OracleDriver").newInstance();
  java.sql.Connection conn =
    Driver.connect("<DB_USER>", props);

2 comments:

  1. hello vikram , the same i got in my quality Server ..from Quality App server to Quality DATABASE server..same o/p .But getting Invalid username /password messgae in my production live running server,even the login credentials are true as per DATASource configurations in Admin console of WLS 11g.

    ReplyDelete
  2. Hi Kalyan,

    --> Invalid username password states the credentials you are using are invalid. Double check your credentials. Are you trying to connect to the correct database ? Check this by directly connecting to the DB.


    --> Could you please paste the complete o/p here...Will try to look into and suggest...

    ReplyDelete