Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> JDBC OracleConnection setClientIdentifier method

JDBC OracleConnection setClientIdentifier method

From: Tom Maki <yymakit_at_retek.com>
Date: 23 Mar 2004 08:51:21 -0800
Message-ID: <a545f2fc.0403230851.31f04e8d@posting.google.com>


Hi,

Has anyone tried using the setClientIdentifier/clearClientIdentifer methods on OracleConnection? We use a connection pool in our app and want a way to be able to trace database calls from a given user and thought this would suit our needs.

I'm using the 10g (10.1) JDBC thin client driver (ojdbc14.jar). When I execute a query after calling the setClientIdentifier method on OracleConnection I get this exception:

java.sql.SQLException: No more data to read from socket

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
at oracle.jdbc.driver.DatabaseError.check_error(DatabaseError.java:885)
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:991)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:941)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:432)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:112)
at oracle.jdbc.driver.T4CStatement.execute_for_describe(T4CStatement.java:351)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:896)
at oracle.jdbc.driver.T4CStatement.execute_maybe_describe(T4CStatement.java:383)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:986)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1125)
at Test.main(Test.java:20)

Here is a sample program to reproduce the error:

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import oracle.jdbc.driver.OracleConnection; import oracle.jdbc.pool.OracleDataSource;

public class Test
{

public static void main(String[] args)
throws SQLException, ClassNotFoundException
{

OracleDataSource dataSource = new OracleDataSource();

dataSource.setURL("jdbc:oracle:thin:@dev17:1521:dev01");
dataSource.setUser("scott");
dataSource.setPassword("tiger");

OracleConnection conn = (OracleConnection) dataSource.getConnection();

conn.setClientIdentifier("me");
Statement statement = conn.createStatement(); ResultSet rs = statement.executeQuery("select sysdate from dual"); //fails here
rs.next();
System.out.println(rs.getString(1));
rs.close();
statement.close();
conn.clearClientIdentifier("me");

conn.close();
dataSource.close();
}
}

I got a similar error using the 9i driver, as well.

Any ideas?

Thanks,
Tom

p.s. since setClientIdentifier/clearClientIdentifer in the 10g drivers what should one use instead? Received on Tue Mar 23 2004 - 10:51:21 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US