Ojdbc driver error - java

I'm trying to optimize the performance of querys from my Java application to the Oracle database, because the same querys doing by sql developer tool are faster than by the java application.
I have two different database (one to test/developer and the other for production).
The developer database version is: 11g Enterprise Edition Release 11.2.0.1.0 - 64bit
The production database version is: 11g Enterprise Edition Release 11.2.0.3.0 - 64bit
My java application was using ojdbc14 driver, that works fine for both databases, but the performance querys are working slowly. So after investigate, I read that a good way to start to improve the performance was using the correct ojdbc driver in the java application (according the database version). So I downloaded the ojdbc6 driver (for 11.2.0.3 oracle version). That work fine in the developer database, but i have the next error when im trying to connect the production database:
java.lang.NoSuchMethodError: oracle.i18n.text.converter.CharacterConverterOGS.getInstance(I)Loracle/i18n/text/converter/CharacterConverter;
I tried with different ojdbc driver version (5, 6), but I get the same error, in the production database only.
Some help?
Sorry my english.
Regards.
Edit 1:
#CSK
I'm using Spring MVC, here is my ApplitacionContext xml for the database connection:
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driverClassName}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="maxPoolSize" value="${jdbc.maxPoolSize}" />
<property name="minPoolSize" value="${jdbc.minPoolSize}" />
<property name="maxStatements" value="${jdbc.maxStatements}" />
</bean>
<bean id="dataSourceDataStage" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.datastage.driverClassName}"/>
<property name="jdbcUrl" value="${jdbc.datastage.url}"/>
<property name="user" value="${jdbc.datastage.username}"/>
<property name="password" value="${jdbc.datastage.password}"/>
<property name="maxPoolSize" value="${jdbc.datastage.maxPoolSize}" />
<property name="minPoolSize" value="${jdbc.datastage.minPoolSize}" />
<property name="maxStatements" value="${jdbc.datastage.maxStatements}" />

I think there're some thing wrong with your classpath in production. So, if possible, try to add jar file (orai18n.jar) directly to your project and recheck again.
In my case, it worked & Hope it help!

Related

Spring Throws "ERROR SqlExceptionHelper: Already closed" after timeout

I have a spring application hosted on to the server (Tomcat 8.5). It goes idle if no one uses it. I already knew that timeout will occur if the DB is in idle state for 8 hours (Default timeout of MySQL). As mentioned in Spring Autoreconnect and Connection lost overnight post i have tried the solution available here.I have tried configuring application.properties but that doesn't bring any solution to the problem.
(PS:I'm not changing anything other than application.properties in my Spring Application).
Well if this
spring.datasource.testWhileIdle = true
spring.datasource.timeBetweenEvictionRunsMillis = 60000
spring.datasource.validationQuery = SELECT 1
or this
spring.datasource.testOnBorrow=true
spring.datasource.validationQuery=SELECT 1
didnt work maybe try this
Post SpringBoot 1.4 names have changed
They have defined new specific namespaces for the four connections pools spring supports: tomcat, hikari, dbcp, dbcp2.
spring.datasource.tomcat.testOnBorrow=true
spring.datasource.tomcat.validationQuery=SELECT 1
If problem doesn't solve even after including properties as in application.properties, Then problem will be solved when including testOnBorrow,validationQuery in application-context.xml located in src/main/resources
<bean name="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${database.driver.classname}"/>
<property name="url" value="${database.url}"/>
<property name="username" value="${database.username}"/>
<property name="password" value="${database.password}"/>
<property name="initialSize" value="2"/>
<property name="maxActive" value="50"/>
<property name="maxIdle" value="5"/>
<property name="maxWait" value="-1"/>
<property name="removeAbandoned" value="true"/>
<property name="removeAbandonedTimeout" value="600"/>
<property name="logAbandoned" value="true"/>
<property name="testOnBorrow" value="true" />
<property name="validationQuery" value="SELECT 1" />
</bean>
The solution is to validate connection thread when it is borrowed from thread pool by enabling testOnBorrow and providing validationQuery.

Could not get JDBC Connection nested exception SQLException Unable to load authentication plugin 'caching_sha2_password'

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/abc" />
<property name="username" value="root" />
<property name="password" value="root" />
</bean>
I have updated MySQL Connector/J to 8.0.14 but still getting the same error.
Thanks in advance.
Try the below command. It might solve.
sample username / password => student / pass123
ALTER USER 'student'#'localhost' IDENTIFIED WITH mysql_native_password BY 'pass123';
How to resolve Unable to load authentication plugin 'caching_sha2_password' issue(SO)
If above doesn't work try to use MYSQL driver which supports MYSQL 8.
MySQL and Java Versions They Support
Installed mysql 5.5 version and it worked fine with that.
Thanks for your help.

Spring Batch - ORA 12516 SQLState 66000 - TNS:Listener could not available handler with matching protocol stack

When I run Spring batch to process more than 100 records, I am get following error,
"Listener Refused the connection with the following error: ORA-12516,
TNS:Listener could not available handler with matching protocol stack".
But when I run the batch to process less than 50 records, it works fine.
In my batch's before step of my reader, I query DB to get records.
e.g. If I get 100 records from DB, Using Loop, I extract a particular field from each record and using the particular fields i will query to another table. So the second query run for 100 times inside the for loop.
In Logs, I can see the batch runs for a while (queries some records inside for loop) and then it throws the error.
Please help me to solve this.
OnlyGod Team -
Oracle database server's value for "PROCESSES" has been configured too low
you can resolve it by steps
Launch 'SQL Plus'
Logon as 'system'
Type the following command (to check that the database is using spfile):
show parameter spfile
Assuming that it shows that you ARE using spfile, then type the following command:
alter system set PROCESSES=300 scope = spfile
Obtain some downtime (nobody using the databases) and restart the Oracle database server (or simply the relevant Oracle database) or you can edit it in notepad++
Changed my data source bean from
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${database.driverClassName}" />
<property name="url" value="${database.url}" />
<property name="username" value="${database.username}" />
<property name="password" value="${database.password}" />
</bean>
to this
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${database.driverClassName}" />
<property name="url" value="${database.url}" />
<property name="username" value="${database.username}" />
<property name="password" value="${database.password}" />
<property name="connectionProperties" value="initialSize=1,maxTotal=10" />
</bean>

SSl over Informix JDBC doesn't work under JBOSS 7

I want to use my Informix JDBC application over SSL. The DBMS is Informix IBM 11.70.
I'm using a spring-config.xml file in which I declare the datasource bean:
<!-- Data source -->
<bean id="dataSource" class="com.sopra.datasource.CustomDataSource" init-method="init"
destroy-method="close">
<property name="url" value="${url}" />
<property name="driverClassName" value="${driverClassName}" />
<property name="username" value="${username}" />
<property name="password" value="${password}" />
<property name="removeAbandoned" value="true" />
<property name="initialSize" value="20" />
<property name="maxActive" value="30" />
</bean>
The problem is that when I deploy my application in Tomcat 7 everything goes well (both TCP and SSL mode), however, when I deploy it in JBOSS 7.1 the SSL connexion mode to the Informix database doesn't work!
When it comes to debugging, the only information that I have is the following :
Application side:
Caused by: com.informix.asf.IfxASFException: Attempt to connect to database server (my_server_ssl) failed.
at com.informix.util.IfxErrMsg.getLocIfxASFException(IfxErrMsg.java:751) [jdbc-4.10.7.20160517.jar:4.1.0.SNAPSHOT]
at com.informix.asf.Connection.openSocket(Connection.java:1864) [jdbc-4.10.7.20160517.jar:4.1.0.SNAPSHOT]
at com.informix.asf.Connection.<init>(Connection.java:427) [jdbc-4.10.7.20160517.jar:4.1.0.SNAPSHOT]
at com.informix.jdbc.IfxSqliConnect.<init>(IfxSqliConnect.java:1416) [jdbc-4.10.7.20160517.jar:4.1.0.SNAPSHOT]
... 47 more
Caused by: java.lang.NullPointerException
at com.informix.asf.Connection.getEnabledSSLProtocols(Connection.java:2242) [jdbc-4.10.7.20160517.jar:4.1.0.SNAPSHOT]
at com.informix.asf.Connection.openSocket(Connection.java:1805) [jdbc-4.10.7.20160517.jar:4.1.0.SNAPSHOT]
... 49 more
Thanks in Advance.
This was due to a defect in the 4.10.7 version of the driver. Try upgrading to either 4.10.8 or 4.10.9 versions. They can be found via maven or through your IBM download site.
Gradle
compile group: 'com.ibm.informix', name: 'jdbc', version: '4.10.9'
Maven
<dependency>
<groupId>com.ibm.informix</groupId>
<artifactId>jdbc</artifactId>
<version>4.10.9</version>
</dependency>

Configure two PostgreSQL database(fail over mechanism) using Spring 3

I am using Tomcat JDBC API(org.apache.tomcat.jdbc.pool.DataSource) to connect to my PostgreSQL database from Spring configuration file as shown below. I got a new requirement to configure two databases which should act as a fail over mechanism, Like When one database is down application should automatically switch back to another database.
<bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource"
destroy-method="close">
<property name="driverClassName" value="org.postgresql.Driver" />
<property name="url" value="jdbc:postgresql://localhost/dbname?user=postgres" />
<property name="username" value="postgres" />
<property name="password" value="postgres" />
<property name="maxActive" value="5" />
<property name="maxIdle" value="5" />
<property name="minIdle" value="2" />
<property name="initialSize" value="2" />
</bean>
Can anyone suggest how this can be achieved using Spring configuration file.
The normal way this is done is by using virtual IP addresses (with possible forwarding), checking for activity, a shoot-the-other-node-in-the-head approach and proper failover. Spring is exactly the wrong solution to this if you want to avoid things like data loss.
A few recommendations.
repmgr from 2ndquadrant will manage a lot of the process for you.
Use identical hardware and OS and streaming replication.
Use virtual IP addresses, and the like. Use a heartbeat mechanism to trigger failover via rempgr
Then from this perspective your spring app doesn't need reconfiguring.

Categories