initSQL connection pooling

Today I learned how to execute sql statement when you application connect to oracle db using connection polling.

I need to set DATE format on db for connection session, so i found that statement:

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MM-YYYY HH24:MI:SS'


And in db connection context parameter initSQL  put this statement.

     <Resource name="jdbc/baza"
              auth="Container"
              scope="Shareable"
              type="oracle.jdbc.pool.OracleDataSource"
              driverClassName="oracle.jdbc.OracleDriver"
              url="jdbc:oracle:thin:@localhost:1521:oradb"
              initSQL="ALTER SESSION SET NLS_DATE_FORMAT = &apos;DD-MM-YYYY HH24:MI:SS&apos;"
              user="user" password="user" / >
meaning the &apos;  is single quotation mark.


initSQL is new parameter in jdbc, so this doesn't work with ojdbc14.jar instead i recommend to use ojdbc6.jar. :]

you can see all examples on this page:
http://www.tomcatexpert.com/blog/2010/04/01/configuring-jdbc-pool-high-concurrency

Comments

  1. Hi,
    I am facing same issue even using ODBC6 jar.
    Ai am trying to execute the below query in initSQL "ALTER SESSION SET CURRENT_SCHEMA=". Can you please help me on this. Please note, this query is working fine in SQL editor.
    Thanks

    ReplyDelete
  2. Hi,
    I think you don't need to use quotes ( ')
    for example
    connect sys
    ALTER SESSION SET CURRENT_SCHEMA=PLAYGROUND;

    can you provide you stacktrace for more details...
    Best Regards



    ReplyDelete

Post a Comment

Popular Posts