tomcat dbcp and mysql connection pooling - spring

I am using a tomcat dbcp along with spring jdbc. When I start the server for first time and try to load the web-page it fetches the data from database and returns correct result set but when i make some changes to db using editor and try to reload the page, it shows old result set. I tried database logging and can see that query is reached to database. I think the result set is being cached somewhere in the container..Can someone tell me what parameter i need to take care of.
help will be appreciated.
thanks.

AngerClown, thanks for your replies. You got me to the real pain point of the problem.
The real problem was lying on database side. Somehow because of some primary key indexing issues some process has acquired the lock on the table and at the same time my autocommit from query browser was set to false. Because of this when i tried to fetch the data in same transaction changes got reflected but not in other transaction.
Without bothering much about it, I just recreated the table. And now it is working fine.
Thanks a lot.
-Santosh.

Related

It takes more than 10 minutes to generate entities from database in IntelliJ IDEA. How can I improve the speed?

I am using IntelliJ IDEA and JPA Buddy to generate entities from my database. However, every time I open an Entity from DB wizard, it takes a very very long time. Is it okay? Or something wrong with my database/IntelliJ IDEA or JPA Buddy?
My setup is:
Database: Oracle (~2000 tables)
IntelliJ IDEA: 2022.3.1
JPA Buddy: 2022.5.3
I have tried to recreate db connection and invalidate caches in the IntelliJ IDEA, same result.
It may happen due to a slow internet connection or many tables in the database (probably it is your case, 2000 is great number). Also, some database drivers are not showing their best side in this matter. The one way you can speed up your development process – is a "schema cache" option from JPA Buddy (1). Using it, you can generate the data model snapshot once and then use its local copy.
Just don't forget to refresh it when the database gets changed (2).

Strange situation with Oracle RAC database

We had a very unusual situation at work. Giving a bit of context first, the setup is: we have a Java application, using Spring Boot and Hibernate, connected to an Oracle RAC database.
We added an item to one of the database tables using that application. We could SELECT this object, and we could UPDATE it... but only for a couple of minutes. Then it simply vanished.
We though it could have been removed by someone, but according to the DBA logs, there wasn't any INSERT in that table during that whole day; although, the person which added the item happened to be recording her screen, so we know for sure that it happened, and when it happened.
How could this situation happen? There were no errors in the application logs indicating that there could have been an error during commit. And during the times we updated the item, it had to be listed first, using a SELECT.
Also, we never had a situation like that one before, and we have been using that same database, and that same application, together, for over a year.
In case I missed any relevant details, just ask.

Datasource changes to secondary on run time if primary is offline

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.

How to clear OBIEE cursor cache (presentation server)

I'm having an issue with a prompt in OBIEE 10g, such that it displays old database value due to the prompt query being serviced from cursor cache (presentation service). For example, if the prompt drop-down shows 1 value initially since there is 1 database row and when i delete this row from database, the prompt still shows the same database value unless i manually delete the cursor cache through analytics
Setting > Administration > Manage sessions > clear cache/cursors
Tried checking OBIEE presentation service config file instanceconfig.xml, however there is no such parameter to permanently disable this cache. I referenced the following link, OBIEE 10G/11G - Presentation Service (Query|Result|Cursor) Cache
Resetting these parameters didn't seem to have any impact on the cursor cache, these are still getting generated and are not cleared after the timeouts set. (I have restarted the OBIEE services after changing these parameters). Am I missing something here.
Would appreciate any pointers to get this done i.e. getting cursor cache cleared/disabled without manual intervention as mentioned above (through Settings > Administration).
At some point I also faced that issue. The presentation cache in OBIEE is a bit shady sometimes.
What I did is to add some dummy comparison on the query of the prompt, involving sysdate with enough precision so it makes each query different to the cache.
It's a bit shabby, but at least you don't need any manual intervention... Maybe it can help you.
Good luck!
You may see this issue if using a Presentation variable as well, rather than a Prompt built using a SQL query.
The problem may be due to shared Presentation Services Query Cache, which means
that even when the user logs out, the query cursor cache is still being shared by other users, so it does not refresh the new data after the user logs in again.
The cache file is in
ORACLE_INSTANCE/tmp/OracleBIPresentationServices/coreapplication_obipsn/obis_temp
See this document for more detail.
You can configure the Virtual Private Database option in the repository
physical database object and mark session variables as Security Sensitive in
the repository to make the query cache not shared among users. See this
documentation for more detail.

What should be approach?

Try to be more clear, I'm in lack of ideas in this problem, even it sounds like a classic.
My application is running on weblogic 10.3.3 application server, and for database I am using Oracle database 11g. My problem is that there is table in db, let's say "user.", there is column, let's say "columnA", in this table. This table is updating by some module of application.
What I want if when value of column is "abc.", then I have to show alert to console(IP). {IP can be retrieved from DB as it is configured in DB. this ip will be other linux system other than linux machine where oracle database is installed.} Updating is continuously done on my table from module of application. Please tell me from where should I start?, what should I read. I am not able to understand what should be approach. Any help is much appreciated.
A trigger on the table can call UTL_HTTP to communicate with another machine (eg call a RESTful API).
The architectural questions are :
This will happen PRIOR to the commit so you may get false alerts if a change is rolled back
If you wait for a response, it will slow the system down.
What do you do if you get an non-standard response (eg the other server isn't available)

Resources