Friday, September 7, 2012

How to find the JDBC Driver Details in Weblogic


#JDBC Driver Details in Weblogic:
#-----------

import java.sql.*;  
public class dbinfo  
{  
  public static void main (String arr[]) throws Exception  
  {  
    String dbDriver="oracle.jdbc.driver.OracleDriver";  
    String dbURL = "jdbc:oracle:thin:@test-db:1521:testsid";  
    String dbPW = "my_password";  
    String dbUser = "my_username";  
   
    Connection con = null;  
    Class.forName(dbDriver);  
   
    con = DriverManager.getConnection (dbURL, dbUser, dbPW);  
    con.setAutoCommit(false);  
   
    DatabaseMetaData dbmd = con.getMetaData();  
   
    System.out.println("=====  Database info =====");  
    System.out.println("DatabaseProductName: " + dbmd.getDatabaseProductName() );  
    System.out.println("DatabaseProductVersion: " + dbmd.getDatabaseProductVersion() );  
    System.out.println("DatabaseMajorVersion: " + dbmd.getDatabaseMajorVersion() );  
    System.out.println("DatabaseMinorVersion: " + dbmd.getDatabaseMinorVersion() );  
    System.out.println("=====  Driver info =====");  
    System.out.println("DriverName: " + dbmd.getDriverName() );  
    System.out.println("DriverVersion: " + dbmd.getDriverVersion() );  
    System.out.println("DriverMajorVersion: " + dbmd.getDriverMajorVersion() );  
    System.out.println("DriverMinorVersion: " + dbmd.getDriverMinorVersion() );  
    System.out.println("=====  JDBC/DB attributes =====");  
    System.out.print("Supports getGeneratedKeys(): ");  
    if (dbmd.supportsGetGeneratedKeys() )  
      System.out.println("true");  
    else  
      System.out.println("false");  
  
    pstmt.close();  
    con.close();  
  }  
  
}  

--------------------------------------------------------------
We can find the jdbc driver version with out programming also 

Go to your weblogic home and set the env as shown belwo
/oracle/app/product/fmw/wlserver_10.3/server/bin> . ./setWLSEnv.sh

Now enter the following weblogic utils command as below.

/oracle/app/product/fmw/wlserver_10.3/server/bin> java weblogic.utils.Versions

Now you can see the jdbc driver version  along with other details.

JDBC ImplVersion: 11.2.0.3.0

No comments:

Post a Comment