Does a java application that uses JDBC 4 driver type requires db2 binding - jdbc

Our java applications will access legacy mainframe db2 databases.
I remember in my previous projects, C++ applications required db2 binding before deployment.
In current projects, all mainframe applications, Cobol packages are also required to do db2 binding.
Does a java application that uses jdbc4 driver needs db2 binding too?

If you are using standard JDBC you are creating dynamic SQL (PrepareStatement) that do not requires binding in DB2 side.
However, if you use SQLj, you will need to 'precompile' that code to generate you .java files and another file to bind in the database.
It does not matter if you are connecting to a mainframe (system z or i) or to a DB2 LUW. The concept is the same for all platforms as DB2 is DB2.
SQLj is not very popular, however is very powerful to tune your queries and improve the data access, however, as you used to do in C, the code has to be developped in more phases, and you have to rebind each time the access plan has to be modified (new statisques, security, etc.)
SQLj is very easy to use from Data Studio, and SQLj from DB2 is not exactly the same from Oracle.

The JDBC type IV driver, supplied by IBM, will handle everything you need to do.
The driver maps Java objects into DB2 appropriately.
I don't know what "binding" means in this context. Java is not C++.

If your DB2 version supports Dynamic Statement Caching and enabled (consult your DBA’s), you can use JDBC Type-4 driver to access mainframe DB2 database (use prepare statement) without binding.
DB2 will generate access paths and store it in first request into cache. Otherwise, you need use SQLJ like technologies and bind them.

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

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.

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.

Migrating from Apache Cassandra 2.2 to Oracle Coherence Oracle 12

I am looking for a migration path for a Java-based project which uses Apache Cassandra 2.2 to Oracle Coherence 12 – and Oracle 12 backend.
The existing application uses CQL to interact with a 3 node Cassandra cluster.
Elswhere we specifically do not use any ORM (e.g. Hibernate/JPA) but use JDBC to interact with the database directly.
Yes, Cassandra is free while the Oracle solution is quite expensive but this is outside the scope of this question.
Any technical suggestions are welcomed.
You have a couple of options depending on your use case.
If you are using the SQL to interact with Cassandra for standard request/response interactions and need to migrate it to use Oracle DB which would require the least code changes and still use a standard approach would be to use an Object Relational Mapping (ORM) tool like Hibernate/JPA and use Coherence as the L2 cache (personally I like MyBatis since you have complete control over the SQL code. You may be able to use this Coherence integration with MyBatis ).
If you have other applications/ops users updating the database directly and need those changes to be available to your application then you will need to implement a CacheStore (use your favorite ORM here if you like) to save updates to the database and use Oracle Golden Gate Hotcache feature to push updates made to the database outside your application to Coherence. Your application will need to be changed to interact with Coherence directly using either their Map interface or using the Coherence Query Language (CQL) which is "SQL like". This approach will have an additional advantage of being able to support any asynchronous use cases you may have as Coherence API supports listening to cache changes (using MapListeners) similar to Cassandra's executeAsync.
I hope this helps.

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

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.

Resources