Method setClientIdentifier() Not Found In Interface oracle.jdbc.OracleConnection for JDBC 10g [ID 369236.1]  

  Modified 27-MAY-2009     Type PROBLEM     Status MODERATED  

In this Document
  Symptoms
  Cause
  Solution


This document is being delivered to you via Oracle Support's Rapid Visibility (RaV) process, and therefore has not been subject to an independent technical review.

Applies to:

JDBC - Version: 10.1.0.0 to 11.1
This problem can occur on any platform.

Symptoms

An application using the JDBC Driver 10.2.0.1.0 is getting some errors like setClientIdentifier method is not valid in the oracle.jdbc.OracleConnection interface.

Error: method setClientIdentifier() not found in interface oracle.jdbc.OracleConnection

Cause

The method setClientIdentifier() was deprecated since the package
oracle.jdbc.driver.OracleConnection and now that all that packages content was moved to the
oracle.jdbc package this method is not there anymore.

The interface oracle.jdbc.driver.OracleConnection has deprecated the method setClientIdentifier().
Oracle started to move the content from the oracle.jdbc.driver to the oracle.jdbc package and all
deprecated methods and not public methods are not there anymore.

Solution

As the method setClientIdentifier is deprecated, it is necessary to use an alternative method for
metric purposes as described in the documentation.

It can be used the new method setEndToEndMetrics as indicated in the documentation.

Oracle® Database
JDBC Developer’s Guide and Reference
10g Release 2 (10.2)

http://download-west.oracle.com/docs/cd/B19306_01/java.102/b14355.pdf

page 30-1.

Sample code:

import java.io.IOException;
import java.sql.*;
import oracle.jdbc.OracleConnection;

public class vSession
{
  public vSession()
  {

  }

  public static void main(String[] args)
  {
    vSession vSession = new vSession();

    try
    {

      // Load the Oracle JDBC driver
      // Change the following code line to reflect a valid connection to your
      // server

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

      String url = "jdbc:oracle:thin:@mhernand-us2.us.oracle.com:1521:V102010";
      java.util.Properties prop = new java.util.Properties();
      prop.put("user","scott");
      prop.put("password","tiger");
      prop.put("v$session.program","jdbc thin driver");
      prop.put("v$session.osuser","Mike");
      java.sql.Connection conn = (new oracle.jdbc.OracleDriver()).connect(url,prop);

      String[] metrics = new String[OracleConnection.END_TO_END_STATE_INDEX_MAX];
      metrics[OracleConnection.END_TO_END_CLIENTID_INDEX]="module-name";
      ((OracleConnection)conn).setEndToEndMetrics(metrics,(short)0);

      // make a network roundtrip make sure the module name is updated
      // since, end2end tracing is a piggy back message.

      Statement stmt = conn.createStatement ();
      stmt.executeQuery ("SELECT USER FROM DUAL");
      System.in.read(); // => This line is just to stop until you press enter. 

      // Before you hit enter you can execute the next select statment to check
      // this information in the v$session.
      //
      // select osuser, program, client_identifier
      // from v$session; 
      //

      System.out.println("\n=============");
    }
    catch (SQLException e)
    {
      e.printStackTrace();
    }
    catch (IOException ioe)
    {
      ioe.printStackTrace();
    }
  }
}



Show Related Information Related


Products
  • Middleware > Developer Tools > Java Development > JDBC