Playframework 2 with Oracle throws InvocationException - oracle

When running the "java/computer-database" sample with an Oracle db instead of the H2 one, Computer.find.byId() results in "com.sun.jdi.InvocationException occurred invoking method.".
The Application.list() is showing the correct data.
I have this in my application.conf:
db.default.url="jdbc:oracle:thin:#xx.xx.xx.xx:1521:somename"
db.default.driver=oracle.jdbc.driver.OracleDriver
In my lib directory I have
ojdbc6.jar
orai18n.jar
When searching for examples on how to use oracle in playframework 2.0, I noticed that you should have a line similar to this one in application.conf:
jpa.dialect=org.hibernate.dialect.Oracle11gDialect
However, this (or any other version number I can come up with) gives an error :
PersistenceException: No Persistence provider for EntityManager named org.hibernate.dialect.Oracle10gDialect
I have already placed hibernate-3.3.2.jar in my lib folder, but somehow play is not using it.
Does anybody know how to fix this, so I can use oracle with the play! framework 2.0?

Related

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?

Oracle SODA : Not all return parameters registered

I am trying to insert a document into oracle12c using SODA lib using example.
I have created a collection using SODA. Now I am trying to insert a document, But I am getting the exception while inserting doc.
Caused by: java.sql.SQLException: Not all return parameters registered
at oracle.jdbc.driver.OracleStatement.processDmlReturningBind(OracleStatement.java:4876)
at oracle.jdbc.driver.OraclePreparedStatement.setupBindBuffers(OraclePreparedStatement.java:3101)
at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:2355)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3579)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3665)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1352)
at oracle.soda.rdbms.impl.TableCollectionImpl.insertAndGet(TableCollectionImpl.java:784)
Code
final OracleCollection countersCollection = database.openCollection(SC_LMS_SEQUENCE_COLLECTION);
countersCollection.insertAndGet(database.createDocumentFromString("{\"id\" : \"COURSE_SEQ\",\"seq\" : 0}"));
Is something I am missing??
The issue is due to the mismatch of ojdbc.jar.
The official document says,
If you're using JDK8 or above, you could use ojdbc8.jar that ships with Oracle Database 18c. Alternatively, you can also use ojdbc8.jar that ships with OracleDatabase 12.2.0.1. If you're still on JDK7 or even JDK6, you can use ojdbc7.jar or ojdbc6.jar respectively. These ship with Oracle Database 12.1.0.2, and are downloadable from this page.
My project is using JDK 7 and project has custom ojdbc6 jar and version 11.3. Then I replace ojdbc7.jar(downloaded from this link.) with my custom jar.
Due to this change above exception is gone and the code works well.

WebLogic ModuleException on Hibernate Dialect

The database group recently upgraded the database to Oracle12c. I am currently using Hibernate 4.3.9. When I try to deploy the application, WebLogic throws an exception:
weblogic.application.ModuleException: org.hibernate.HibernateException: Unable to determine dialect to use [name=Oracle, majorVersion=12]; user must register resolver or explicitly set 'hibernate.dialect'.
HibernateUtil has
props.setProperty("hibernate.dialect", "utilities.OracleDialectExtended");
Where OracleDialectExtended extends Oracle10gDialect in order to register a Double as a float. HibernateUtil is being used to set the properties rather than in hibernate.cfg.xml.
Everything I have read indicates that using Oracle10gDialect should be OK. In fact, when I use the same set up in a batch type mode (not using WebLogic) I am able to connect with and work with Oracle without a problem.
Does anyone know how to resolve this? Or is this a WebLogic problem that needs to be addressed by a WebLogic admin.
Thanks.
Try with this:
props.setProperty("hibernate.dialect","org.hibernate.dialect.OracleDialect");
Just to follow up - in the end I upgraded Hibernate from 4.3.9 to 5.1.2 and things started working again.
Not the most ideal solution since a database upgrade shouldn't break an application but it was the fastest way to get things up and running again.

AbstractMethodError When using Jboss5 and Hibernate 4

I am trying to Upgrade my Spring 1.9 Application to Spring 4 and therefore I also have to upgrade Hibernate. As database I am using Oracle.
When starting the application everything is fine until I am using Clobs, then the following Exception is thrown:
java.lang.AbstractMethodError:org.jboss.resource.adapter.jdbc.jdk5.WrappedPreparedStatementJDK5.setCharacterStream(ILjava/io/Reader;J)V
I also already upgradet my JDBC driver, does anyone have hint, what else to try?
The problem is the jboss-common-jdbc-wrapper.jar located under ${JBOSS_HOME}\common\lib obviously it was implemented against an Interface which was created in a version which is less then JDK_1.6. Therefore the method was never implemented though.
After replacing this Jar, with the same vom a JBoss AS 6.1 everything is working fine.
BR

ClassCastException: org.jboss.jca.adapters.jdbc.jdk6.WrappedPreparedStatementJDK6 cannot be cast to OraclePreparedStatement

I'm working to migrate an application from Oracle Application Server to JBoss EAP 6.1. I have most things working but I am getting one error that I haven't been able to figure out:
13:27:29,743 ERROR [com.myproj.db.dao.myDao] (Thread-164) Get Prepared Statement:
java.lang.ClassCastException:
org.jboss.jca.adapters.jdbc.jdk6.WrappedPreparedStatementJDK6 cannot be cast
to oracle.jdbc.internal.OraclePreparedStatement
I have Oracle set up as a module in JBoss for connection pooling using ojdbc6.jar (and it works for other parts of the application), but for the one part of the application that uses an OraclePreparedStatement, it gets the error.
I did make certain that there is no ojdbc6.jar file in the WAR file. The only one in JBoss seems to be inside of the module.
I did try changing the OraclePreparedStatement class to oracle.jdbc.OraclePreparedStatement, but the results are the same.
I did try running with TRACE on for logging to see where classes were loading from. OraclePreparedStatement was loaded from the module with the exception of this line:
4:31:40,583 TRACE [org.jboss.modules] (Thread-84) Finding class
oracle.jdbc.OraclePreparedStatement from Module "deployment.myProj.war:main" from
Service Module Loader
Here's a link to an excerpt of the log - basically just the lines related to OraclePreparedStatement.
I have confirmed that there is no ojdbc6.jar (or any Oracle related jars) in the WAR file, and there is no OraclePreparedStatement class inside of the WAR file either.
I do have the module listed as a dependency in my JBoss deployment structure xml file.
Anyone have any ideas?
From looking at the javadoc I would guess that org.jboss.jca.adapters.jdbc.jdk6.WrappedPreparedStatementJDK6 is wrapping the underlying Oracle JDBC driver.
org.jboss.jca.adapters.jdbc.jdk6.WrappedPreparedStatementJDK6 has a method to get the underlying statement. Perhaps you should try something like the following:
WrappedPreparedStatementJDK6 statement = ...
OraclePreparedStatement oracleStatement = (OraclePreparedStatement)statement.getUnderlyingStatement();

Resources