Flyway: use Oracle OCI - oracle

Flyway's primary Oracle driver is JDBC Thin, configured as below:
URL jdbc:oracle:thin:#//host:port/service or jdbc:oracle:thin:#tns_entry.
JAR's are ojdbc8.jar and orai18n.jar, main class is: oracle.jdbc.OracleDriver.
Is it possible to use Oracle OCI driver instead of JDBC Thin? if yes then how to configure this?

Related

Can I use OJDBC7 on a Oracle 11gR2 database?

Can we use Oracle 11g database with ojdbc7 for Oracle 12c (12.1) without any problem. Will new JDBC driver for Oracle Database 12c including a Java 7 JDBC driver (ojdbc7 - 12.1.0.1) still work If I upgrade my application server containing ojdbc7 for Oracle 12c.
Can we use Oracle 11g database with ojdbc7 for Oracle 12c (12.1) without any problem.
Yes you can, as shown in the table in the Oracle JDBC FAQ entry Which version of JDBC drivers support which version of Oracle database?:
Please refer to the table below for the Oracle database versions
supported by JDBC drivers. Best Practice that we recommend is, JDBC
driver version should always be either same as or higher than the
Oracle database version being used in order to leverage the latest
capabilities of the JDBC driver.
Interoperability Matrix DB 12.2.0.1 DB 12.1.0.x DB 11.2.0.x
JDBC 12.2.0.1 Yes Yes Yes
JDBC 12.1.0.x Yes Yes Yes
JDBC 11.2.0.x Yes Yes Yes
In other words, you can even upgrade to Oracle JDBC driver version 12.2.0.1 (which only supports Java 8), and still use that with Oracle 11g.
The driver might even work with earlier versions of Oracle, but this is not officially supported.
Note that ojdbc7 is not an indication of version, it just indicates that Java version it targets (ojdbc6 -> Java 6, ojdbc7 -> Java 7, ojdbc8 -> Java 8), and that again determines the supported JDBC specification version.

JDBC thin driver

The question I have is why does Oracle SQL developer does not require Oracle client installed on local?? I searched on the internet and found that it makes use of JDBC thin driver. Can someone please throw some light on this topic?
The Oracle thin driver is a so-called JDBC Type 4 driver, which is implemented purely in Java without native dependencies (.dll/.so), and has a full implementation of the Oracle wire protocol. In other words the thin driver does not require the Oracle client installed, as it doesn't use it.
There are also JDBC Type 2 drivers which do use native dependencies; Oracle has a Type 2 driver as well which is known as the Oracle JDBC OCI driver. This driver uses a JDBC url that is prefixed with jdbc:oracle:oci:.
The Type 1 and Type 3 drivers I ignore because they are hardly relevant these days.

Jdbc settings for connecting to Impala

What is the combination of driver and jdbc URL to use for CDH5 (I am on CDH5.3)?
I have tried a few including:
jdbc:hive2://myserver:21050/;auth=noSasl
And with the following driver:
org.apache.hive.jdbc.HiveDriver
I have added
/opt/cloudera/parcels/CDH/lib/impala/lib/*:/opt/cloudera/parcels/CDH/lib/hive/lib/*
to the classpath (but still no success)
The result is:
java.sql.SQLException: No suitable driver found for jdbc:hive2://myserver:20150/;auth=noSasl
Firstly, make sure you're using the correct driver. You should use the Impala JDBC driver (rather than the Hive driver).
Then you should be able to use the com.cloudera.impala.jdbc3.Driver driver with a connection string like: jdbc:impala://host:21050
The Impala JDBC driver guide has more details and examples.

Loading a jdbc driver in a java class

In a simple jdbc example , when we load a driver through a java class, the practise is to use Class.forName("com.mysql.jdbc.Driver").newInstance();
Why we do not use new com.mysql.jdbc.Driver();?
This piece of code isn't really intended to create an instance of the driver but to ensure the driver class is loaded by the class loader. Nowadays this is no longer needed, see:
What is the actual use of Class.forName("oracle.jdbc.driver.OracleDriver") while connecting to a database?
JDBC Class.forName vs DriverManager.registerDriver
Loading JDBC driver
What is the purpose of 'Class.forName("MY_JDBC_DRIVER")'?
JDBC connection- Class.forName vs Class.forName().newInstance?

Configure JDBC oracle specific property v$session.program using Jboss and JPA (hibernate)

I'd like to set the v$session.program Oracle property in order to have information available in the session table. I'm using JPA with a jndi XA datasource created with an oracle-xa-ds.xml deployed in the deploy folder of Jboss, and therefore I haven't access to the constructor of the Connection.
I have access to the Connection object, in JPA 2 using unwrap, in JPA 1 by casting JPA to Hibernate classes, but there are no properties setter (only Client Info properties that are the way to proceed starting JDBC 4.0).
So my question is, using JPA (with Hibernate) using Jboss 4.2 :
Is it possible to configure the v$session.program in the persistence.xml ?
Is it possible to configure the v$session.program in the oracle-ds.xml ?
Is their any other approach to the solution ?
Thank you for any valuable comments and answers !
I had the same Problem today, after much fiddeling and reading documentation finally I had the Eureka moment:
Add following parameter:
<xa-datasource-property name="connectionProperties">v$session.program=YourUniqueName</xa-datasource-property>
Thats all.
I'm pretty sure this must be documented somewhere but here is what we can find in the JBoss wiki:
How To Specify "PROGRAM" Oracle Connection Property
JBoss Version: JBoss 4.0.3 SP1, Oracle DB Version: 10g
To be able to distinguish the JDBC
connections on the Oracle server side,
which are created by different JBoss
instances, Oracle's PROGRAM connection
property might be set within the
Oracle specific JDBC datasource config
file by using the following tags:
<connection-property name="v$session.program">ADistinguishedNameForPROGRAMProperty</connection-property>
i.e.
...
<connection-url>AConnectionURL</connection-url>
<connection-property name="v$session.program">ADistinguishedNameForPROGRAMProperty</connection-property>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
...
That way the DBAs can have proper
granularity in:
AWRs
v$session view
Other tools which are checking/evaluating PROGRAM connection
property

Resources