What is difference between oracle.jdbc.xa.client.OracleXADataSource and oracle.jdbc.pool.OracleDataSource - performance

I am trying to understand the difference between XA vs Non XA JDBC datasource. Also how do I know which type and version of JDBC dtriver is used. I am currently on 10.3 weblogic and trying some tet to kill long running queries using setQueryTimeout, which isnt seem to be reliable with OracleXADataSource as it is only working the first time and not always.
Sorry for this basic question but I am new to Weblogic Datasource configuration
Thanks

XA jdbc drivers are used to implement two-phase commit, meaning the two remote resources are part of the same transaction. Java specifies an implementation of this via JTA. A good reading is e.g. http://www.javaworld.com/javaworld/jw-07-2000/jw-0714-transaction.html; if you google for 'xa jdbc driver' you'll find plenty more info.
You should not use the XA driver if not necessary. I remember reading that there are some problems with them.

To identify JDBC driver your WLS is using, go to the <domain_dir>/config/jdbc and open the data souce file, check the driver-name value in the file.
To identify the Driver version, check from which .jar is the driver being loaded (run the WLS with -verbose:class)- the name of the jar will contain the version number. Also, you can use java -jar my-jdbc-file.jar which will print the driver version. The OJDBC drivers are usually stored in a file named ojdbc6.jar or ojdbc7.jar, etc.

Related

How to use p6spy for standalone application that limits its JDBC drivers?

I have a standalone 3rd party application working with Oracle database and I need to troubleshoot its DB queries. And I don't have access to its source code (nor desire to decompile it :-) ).
Its DB connection configuration has several separate parameters:
Driver: oracle.jdbc.OracleDriver
JDBC URL: jdbc:oracle:thin:#localhost:1521:orcl
User name & password
But I can't change driver as application is checking for a list of supported drivers and just refuse to start if I put com.p6spy.engine.spy.P6SpyDriver into the driver parameter.
So can p6spy still be used in this case? If not, is there any other way to trace application DB access from application's end (I'm aware of Oracle tracing, that would be my next step if this won't work)?
Many thanks!
You can use P6Spy in Datasource way

Wildfly using h2 for datasource instead of driver I specified

I added ojdbc6.jar driver to Wildfly as a deployment, and created a datasource which uses the ojdbc6.jar driver. This worked and I was able to access the database in my project - displaying info from the database using a servlet.
However when I restarted my computer it no longer worked (but I hadn't changed anything) and was throwing me org.h2.jdbc.JdbcSQLException even though I am not trying to connect to the h2 database.
So basically Wildfly seems to keep overwriting the setting for my Datasource to use the ojdbc6 driver and changing it to use the h2 driver and I don't know how to stop this.
Can anyone help?
I have seen online for this problem about editing a persistence.xml file but I don't have one.. should I create one?

RazorSQL causes HSQLDB to throw org.hsqldb.HsqlException: Client driver version greater than '2.1.0.0' is required. HSQLDB server version is '2.3.4'

I am not able to connect to my HSQLDB database from RazorSQL. I am only having this issue when I am running in Server mode and when I am attempting to connect from RazorSQL.
Using the same URL from Eclipse Data Source Explorer, and from the application itself (which is a Hibernate 5.2.7 application), I am able to successfully connect to my database at the URL "jdbc:hsqldb:hsql://localhost/SudokuHibernate". Since I am running it in Server mode, I am able to connect concurrently.
(Note: I don't have to have multiple concurrent connections, but it make debugging easier). The database is being run in Server mode from the command line via ...
java -cp ../libs/hsqldb-2.3.4/hsqldb/lib/hsqldb.jar org.hsqldb.server.Server --database.0 file:/Users/arick/src/databases/SudokuHibernate --dbname.0 SudokuHibernate
When attempting to connect from RazorSQL, the database console shows the error message. "org.hsqldb.HsqlException: Client driver version greater than '2.1.0.0' is required. The HSQLDB server version is '2.3.4'".
Note: This is a different question then a similar StackOverflow question, as all of my own configuration files are explicitly referencing the same JDBC driver, from the same jar file. However, as pointed out by Fred T, the reference to '2.1.0.0', by HSQLDB, is somewhat misleading. It is really just saying that the client and the server have two different versions of the JDBC driver.
At the same time that the database is throwing a mismatched version error, RazorSQL displays a dialog box with the error message:
ERROR: An error occurred while trying to make a connection to the database:
JDBC URL: jdbc:hsqldb:hsql://localhost/SudokuHibernate
connection exception: connection failure: java.io.EOFException
Below is my RazorSQL connection profile.
RazorSQL Profile
Driver Location: /Users/arick/src/libs/hsqldb-2.3.4/hsqldb/lib/hsqldb.jar
JDBC URL: jdbc:hsqldb:hsql://localhost/SudokuHibernate
As was inferred by Mark Rotteveel, the answer is similar to a related question about how to get Eclipse and Maven to talk to a HSQLDB server that is running in standalone server mode.
In that case, Fred Toussi, the lead on the HSQLDB project, pointed out the answer was to modify the configuration file, that is used in Eclipse and Maven, to pull in the appropriate version of the HSQLDB JDBC jar file, and also to make sure the jar file didn't appear anywhere else on the classpath. Maven uses a pom.xml file for configuration; so what was needed was make sure that the correct version of the HSQLDB was defined in the project's pom.xml file.
In my situation, the RazorSQL product that I was using, just happens to use HSQLDB as the embedded database for itself. If I had been using any other Java database, I may not have had this problem. But, since the RazorSQL product had already loaded its own version of the HSQLDB jar file, it didn't matter what I specified in my configuration for the database connection. It wasn't going to work.
No matter how I changed my driver profile, or my connection profile, the only version of the HSQLDB jar file that was going to get loaded, was the original jar file, that was already in use by RazorSQL, and that came with RazorSQL. (Note: This is true, unless RazorSQL gets fancy, and it decides to use a different classloader, and some of the other tricks that are commonly used by Java applications servers to solve these problems).
As per suggestion from Dan Richardson, from RazorSQL, the actual answer was not by modifying my configurations, but by changing the contents of the RazorSQL distribution itself. I needed to replace the jar file that is used by the RazorSQL application. This jar file is in Mac application folder for RazorSQL. This location is typically at /Applications/RazorSQL.app/Contents/Java/drivers/hsqldb.
(Note: If you are not familiar with how to open a Mac app folder, you just right-click on the RazorSQL folder name in the /Applications directory and use the "Show Package Contents" menu option). In my case, I renamed the original hsqldb.jar file to be hsqldb_2.3.2.jar file, and then I copied in the last distribution of the hsqldb.jar.

Problems using db2 type 4 drivers with glassfish

I am trying to create a connection pool for a db2 database in glassfish and I'm somewhat new to the entire process. I created the pool yesterday with no problems, I pinged the server successfully and all was well. The next time I start glassfish, my connection pool is gone! After recreating the connection pool with the same settings, the ping is failing with the following error in the server.log:
RAR5099 : Wrong class name or classpath for Datasource Object java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2ConnectionPoolDataSource
I've tried moving the db2 driver .jar files around to lib/ or lib/ext/ and I've played around with the classpath prefixes and suffixes, but I've had no luck. It seems like glassfish isn't finding the drivers but I can't understand why.
BTW: I'm using OS X 10.6 and I configured the connection pool in a pretty basic way. I also added driverType = 4 to the properties.
Thanks in advance for your help!
You need to have the files db2jcc.jar and db2jcc_license_cu.jar in your classpath. The mentioned lib/ext/ should probably do the trick. The correct classname is probably com.ibm.db2.jcc.DB2SimpleDataSource for use with GlassFish.

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