Skip to Main Content
  • Questions
  • Initializing a data source connection with SQL code is known as Init SQL From Java code

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Oussema.

Asked: November 07, 2016 - 12:39 pm UTC

Last updated: November 08, 2016 - 6:33 am UTC

Version: ojdbc6.jar

Viewed 1000+ times

You Asked

I need initializing an oracle data source connection with SQL code .
so this code need to be executed for each physical connection , before being added to the pool

and Connor said...

I'm not sure what you mean, but if you are indicating an SQL that should 'verify' that you can run SQL commands, then:

select 1 from dual

would be a SQL that would be expected to work for every database.

Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Run SQL with datasource physical connection before being added to the pool

Oussema BenJemaa, November 08, 2016 - 7:40 am UTC

My java application, is using JDBC Driver ojdbc6.jar, and i've a requirement to create an oracle datasource with class oracle.jdbc.pool.OracleDataSource and want initialize physycal datasource connection before being added to the Pool , with SQL code known as Init SQL (And this from Java code).

JDBC Info , 'im using

Oussema BenJemaa, November 08, 2016 - 7:53 am UTC

knowing that i'm using foloowing JDBC :

Oracle JDBC Driver version
======================
java -jar oracle-ojdbc6-11.2.0.3.0.jar -version
Oracle 11.2.0.3.0 JDBC 4.0 compiled with JDK6 on Thu_Jul_11_15:43:23_PDT_2013

Oracle JDBC driver type
=======================
Thin


JDK Version
===========
java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)