This discussion is archived
7 Replies Latest reply: Oct 17, 2012 2:35 PM by EJP RSS

How to disable thread safety for OracleDataSource connection

varkashy Newbie
Currently Being Moderated
By default oracledatasource connection are thread safe.
What property shall i set in connectionProperties to disable thread safety?
I want something like isThreadSafe=false
  • 1. Re: How to disable thread safety for OracleDataSource connection
    Joe Weinstein Expert
    Currently Being Moderated
    I don't know what this means. A JDBC connection has no protection from multithreaded use
    except that it will serialize access to the DBMS communication because it must behave as
    a single user sending a series of requests to the DBMS. It remains the responsibility of the
    application author to ensure the connection and it's subobjects are not available for willy-nilly
    multithread use. What symptom do you want to overcome with a threadsafe=false flag?
  • 2. Re: How to disable thread safety for OracleDataSource connection
    varkashy Newbie
    Currently Being Moderated
    i am trying to use JNDI look up for getting database connection
    The connection object is OracleDataSource, this is implicitly thread safe
    I want some way to disable thread safety in JNDI
  • 3. Re: How to disable thread safety for OracleDataSource connection
    Joe Weinstein Expert
    Currently Being Moderated
    Sorry, I still don't understand. A DataSource is not a connection object.
    A DataSource (however you obtain it) delivers connection objects via
    the getConnection() calls. And I don't know what you mean by thread-safe.

    Again I ask, because this will get us closer to solving and/or understanding:

    what is the behavior you observe that you would like to be different?
  • 4. Re: How to disable thread safety for OracleDataSource connection
    varkashy Newbie
    Currently Being Moderated
    I am using JNDI look up to get a data base connection for my clover ETL graph
    In the Clover ETL configuration , we have a property threadSafeConnection=false , this will disable the thread safety of clover ETL.
    I want to migrate this to JNDI lookup, as part of connection property.
  • 5. Re: How to disable thread safety for OracleDataSource connection
    rp0428 Guru
    Currently Being Moderated
    >
    By default oracledatasource connection are thread safe.
    >
    Says who? Please post a citation that states this.

    Certainly many methods of OracleDataSource are synchronized but I've never seen any citation stating that the class is thread safe.
    >
    What property shall i set in connectionProperties to disable thread safety?
    >
    There is none - nor could there be. Thread safety generally depends on synchronized methods so you either call the method or you don't. If you call it it will either already be declared synchronized or it won't; that can't be changed with a flag. And you can't overload a method just to create one version that is synchronized and one that isn't.

    The valid connection properties are documented in the Javadoc in the 'setConnectionProperties' method. There is no property for thread safety.
    http://download.oracle.com/otn_hosted_doc/jdeveloper/905/jdbc-javadoc/oracle/jdbc/pool/OracleDataSource.html#getConnectionProperties()

    The JDBC Developer's guide, chap 8 Data Sources and URLs, also makes no mention of the word 'thread' or 'safe'.
    http://docs.oracle.com/cd/B28359_01/java.111/b31224/urls.htm#i1006362
  • 6. Re: How to disable thread safety for OracleDataSource connection
    Joe Weinstein Expert
    Currently Being Moderated
    That has no relevancy to JNDI lookups, DataSources or Connections. However you get a connection,
    it is up to the application to enforce thread-safety, and JDBC use should always be made thread-safe.
  • 7. Re: How to disable thread safety for OracleDataSource connection
    EJP Guru
    Currently Being Moderated
    966046 wrote:
    I am using JNDI look up to get a data base connection for my clover ETL graph
    In the Clover ETL configuration , we have a property threadSafeConnection=false , this will disable the thread safety of clover ETL.
    I want to migrate this to JNDI lookup, as part of connection property.
    Why?* What benefit do you expect to gain, even if it was possible, which it clearly isn't?

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points