Solution:
Create a file with name JDBCVersion.java in your middle tier (Application Tier)
---------
import java.sql.*;
import oracle.jdbc.driver.*;
class JDBCVersion
{
public static void main (String args[])
throws SQLException
{
// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// Get a connection to a database
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=YES)(FAILOVER=YES)
(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST= <hostname>) (PORT=
<portno>)))(CONNECT_DATA=(SID=<yoursid>)))" ,"apps","<appspaswd>");
// Create Oracle DatabaseMetaData object
DatabaseMetaData meta = conn.getMetaData();
// gets driver info:
System.out.println("JDBC driver version is " + meta.getDriverVersion());
}
}
-----------
Replace following parameters
1. <hostname> with your database hostname or IP address
2. <portno> with your database port no.
3. <yoursid> with SID for your database
4. <appspaswd> with your apps password
After changing save it with name JDBCVersion.java in your middle tier & execute command
[Server@oracle]$ javac JDBCVersion.java
This will create class file in your workign directory. Include your current directory into your
classpath like
export CLASSPATH=/<location where JDBCVersion.class created by above:$CLASSPATH
program>
then execute
[Server@oracle]$ java JDBCVersion
you should see output like
JDBC driver version is 11.2.0.1.0
Which means you are using jdbc thin driver version 11.2.0.1.0
Create a file with name JDBCVersion.java in your middle tier (Application Tier)
---------
import java.sql.*;
import oracle.jdbc.driver.*;
class JDBCVersion
{
public static void main (String args[])
throws SQLException
{
// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// Get a connection to a database
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=YES)(FAILOVER=YES)
(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST= <hostname>) (PORT=
<portno>)))(CONNECT_DATA=(SID=<yoursid>)))" ,"apps","<appspaswd>");
// Create Oracle DatabaseMetaData object
DatabaseMetaData meta = conn.getMetaData();
// gets driver info:
System.out.println("JDBC driver version is " + meta.getDriverVersion());
}
}
-----------
Replace following parameters
1. <hostname> with your database hostname or IP address
2. <portno> with your database port no.
3. <yoursid> with SID for your database
4. <appspaswd> with your apps password
After changing save it with name JDBCVersion.java in your middle tier & execute command
[Server@oracle]$ javac JDBCVersion.java
This will create class file in your workign directory. Include your current directory into your
classpath like
export CLASSPATH=/<location where JDBCVersion.class created by above:$CLASSPATH
program>
then execute
[Server@oracle]$ java JDBCVersion
you should see output like
JDBC driver version is 11.2.0.1.0
Which means you are using jdbc thin driver version 11.2.0.1.0
Thanks buddy. It's superb.
ReplyDelete