Specify v$session.program for R2DBC Oracle connection - oracle

I was trying to set the v$session.program at the connection from a R2DBC Oracle connection (within a Spring application)
For now I've tried this but without success.
ConnectionFactories.get(ConnectionFactoryOptions.parse(dbUrl).mutate().option(Option.valueOf("v$session.program"), "PROGRAMNAME").build());
Would this be possible to set in any way?
Thanks for help.

Oracle R2DBC 0.4.0 does not support the v$session properties as ConnectionFactoryOptions. However, I think it should, so I'll be adding support for that in the next release of Oracle R2DBC.
If anyone needs a temporary workaround, these properties can be set as JVM system properties. System properties will bypass Oracle R2DBC's connection property filter.

Related

Is Spring Data Jdbc recommended for Oracle 18c?

Is Spring Data JDBC v1.1.5 recommended for Oracle Database and Enterprise Applications? Lot of samples around the net based on Open Source RDBMS (H2 or PostgreSQL). We are using Spring Data JDBC in a Spring Boot Microservice Application, facing following problems.
Force to write custom converters for oracle.sql.TIMESTAMP, oracle.sql.TIMESTAMPTZ and oracle.sql.DATE and oracle.sql.ROWID etc..
Can't type cast oracle.sql.ROWID to java.lang.Number
Identity must not be null after save.
Spring Data JDBC is absolutely recommended for Enterprise Applications.
Not so much for use with Oracle.
Since the necessary resources (database & JDBC driver) weren't available in a form that could be easily used in integration tests on public platforms, Oracle isn't included in regular builds.
Therefore it is likely that one encounters issues when working with Oracle.
Some are already known, for others issues in Jira or even PRs are highly appreciated.

JMeter 5.2.1 - Connection properties is ignored

I checked using JMeter 5.2.1 the connection properties feature with oracle
Bug 63926 - JDBC Connection Configuration: Add ability to set connection properties
But even if I give wrong values in Oracle connection options as
user=notexists;internal_logon=irrelevant
JDBC request is executing normal, meaning it didn't use the wrong connection properties
JMeter uses dbcp2's BasicDataSource connection properties, but it seems to be ignoring when sending JDBC queries
I just tried it in 5.2.1 oracle.jdbc.OracleDriver from ojdbc10.jar downloaded from OTN and it works ok (it takes the properties).
In the "JDBC Connection Configuration", did you set the "JDBC Driver Class" as "oracle.jdbc.OracleDriver".
You also need to add ojdbc10.jar in JMETER_HOME/lib/ext.
Here are the images from Pablo.

DB Does Not Reconnect After Connection Drop

I have an application using SpringData, HikariCP and Oracle 11. When the connection to the DB drops and comes back the application is unable to communicate with the DB unless the application is restarted. I tried adding the following properties as some suggested on similar questions but they did not solve the problem.
spring.datasource.remove-abandoned=true
spring.datasource.testOnBorrow=true
spring.datasource.validationQuery=SELECT 1
Any ideas?
These properties are NOT for hikaricp. so they are not in effect.
Refer HikariCP for the supported properties.
For Oracle i think SELECT 1 isn't the appropriate Query.
Can you try :
SELECT 1 FROM any_existing_table WHERE 1=0

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

SQL logging in Websphere 6.1

I am looking for a tool that Logs SQL statemetns fired in the application as I use the application.
I found p6spy. But there is an issue with that. It doesnt seem to be compatible with XA Datasources.
Is there a way to make p6spy work on Websphere 6.1 OR is there an alternative to p6spy ?
Also, if anyone has any AspectJ code that intercepts the PreparedStatment object and dumps the SQL, that would also be great.
It is not mandatory for the JDBC drivers to implement a feature to be able to extract / print out the SQL statements. To be honest, I would do this in database. All reasonable database products can log in detail everything that comes in. Also, you can at the same time get further information like execution plans and their impact on the server.
It does depend on the way that you are accessing the database. If you are using Hibernate then you can make that spit out its SQL, if you are accessing the datasource through WAS then you can use the trace service. Set the trace to something like:
=info: com.ibm.websphere.rsadapter.=detail
And see what you get out of it.
I seem to remember there being some parameter you can add to your jdbc url configuration, and/or the connection. Can't remember the details.
You shold change trace level into jdbc driver.
If you using DB2 then change custom properties for data source
if you using Oracle then change driver on the ojbdc6_g.jar and change JVM properties

Resources