I have following environment:
EAR application on WebSphere 9, container managed transactions using XA datasource for Oracle 19c database (let's name it database "A").
The problem is that datasource (in some transactions), i.e. database "A" is calling database "B" via database link (database "B" is also Oracle 19c).
Connection pool gets "Too many database links in use" error message because of 2 phase commit. Let's say max. number of database links in use is 4, if i refresh screen 5th time i get SQL exception.
Setting maximum database links in use parameter in database properties only delays the problem.
I am in no control (from application perspective) of closing database links.
ATM we've set datasource to non-XA and everything works fine, but in some time we'll need to manualy handle transaction that include one datasource and WebSphere MQ.
Anyone got any ideas or experience with this setup?
EDIT: I'm trying to get this working with JPA 2.0.
You have two options:
If not you, then the developers of the application need to make sure the database links get closed. If your max number of active database links is 4, then you can only have 4 active sessions/users in your application.
Increase the allowed number of database links
This article describes the fixes/workarounds in greater detail.
Related
I am using AbstractRoutingDataSource to store data sources which are stored in database during spring boot application startup.
System can switch to correct database during program running.
When end users manual change database connection information from UI (like change password every 6 months), then sysem need to reload data sources information.
According to testing, even sytem reset target data sources, the old jdbc connection is used.
I have to deal with the following scenario for spring application with Oracle database:
Spring application uses the primary database. In the meantime the secondary database stores data for disaster recovery (from primary).
The first step is currently provided. At this moment I have to implement:
When the primary database gets offline application should change the connection to the secondary database).
The implementation should be programmatically. How can I achieve that without changing the code that currently exists? Is there any working solution (library)?
I think about AbstractRoutingDataSource and ping databases (e.g. every 5 seconds) but I'm not sure about this solution.
So, let's to summarize the issue. I was unable to use Oracle RAC (Real Application Cluster). If the implementation should be programmatically you can try AbstractRoutingDataSource approche.
I have implemented timer that pings current database every 1 second (you can use validation query and check if you can read from database... if no we assume there is no connection and we can switch a datasource).
Thanks to that I was able to change datasource on runtime when current datasource is offline. What is more important it was automatic.
On the other hand, there are disadvantages:
For short time user can see the errors if the database is not
switched yet.
Some part of application may stop working if it is not properly
secured against the lack of connection to the database.
Oracle WebLogic allows initializing database connections with SQL Code (s. http://docs.oracle.com/cd/E13222_01/wls/docs81/ConsoleHelp/jdbc_connection_pools.html#1127542). Is there any way to do this in WebSphere 8?
Please see the Connection validation by SQL query column of the Application programming model row in the deprecation table for the recommended alternative. IBM support cannot provide you with a time frame for removal, as there is no fixed time frame for deprecated features to be removed. At a minimum, the feature will not be removed for 2 releases after deprecation. In this particular case, the feature was deprecated because the JDBC spec now defines similar capability.
Yes it is possible. See WebSphere Application Server data source properties page.
You need to check: Validate new connections and provide your SQL code in the: Validation by SQL string in the Data source properties.
if the glassfish server loses connectivity with the DB the connections all die. I want to detect it and recover the connection.
When I set it to use "table", this works but when i set it to "meta-data", this seems not working. Anybody know why or is this a known glassfish bug?
Likely not bug in GlassFish, but JDBC driver that caches meta data. This is also addressed in GlassFish documentation:
table: Performing the query on a specified table. If this option is
selected, Table Name must also be set. Choosing this option may be
necessary if the JDBC driver caches calls to setAutoCommit() and
getMetaData().
We are running applications on weblogic server. We have a requirement in which we want to monitor jdbc calls made on a data source. We only want to collect time taken for each sql to execute and number of times a sql is fired. I also want to collect this information per user session.
There are a few utilties on the web like weblogic jdbc spy, log4jdbc, etc. But they all required additional setup on the data source and provide output on a separate logging file which does not contain per session output as such. Is it possible to create another weblogic application that listens on a given data source and record all the sql and the timings per session? Please provide any pointers that you have.
TIA,
Siva Rajesh
Oracle JRockit Flight Recorder can be answer for you. I'm using him. Just make a record in defined time and then analyze gathered jfr file with Oracle JRockit Mission Control.
Links:
Oracle JRockit Flight Recorder manual
Oracle JRockit Mission Control
Or you can find your answer with parameter -Doracle.jdbc.Trace=true -Djava.util.logging.config.file=/jdbc/demo/OracleLog.properties