ORA-02020 – Too many database links in use - java

i have a web based application which uses weblogic connection pooling while accessing oracle db. there is a procedure in which i must use db link to fetch and update remote table. but after a few call my service which triggers procedure call i got ORA-02020 – Too many database links in use error.
I think it causes from weblogic connection pool, it does not close session so db link is not closed and it reached max dblink count after a few try.
i've found http://dbtricks.com/?p=198 work around solution but it have not worked for me. i must use db link so what should i do? is there any solution for my case?
thanks.

Related

Providing connection time out in Derby client driver

I have a requirement that retrieving a connection times out within specified time from the connection pool if there is any problem in the network. This should be handled through a java application.
Basically, want to give timeout to datasource.getConnection() method.
So after some research, I found setLoginTimeout(int seconds) method of DataSource has this functionality in order to notify if a database connection can not be made within the specified seconds.
I applied this on OracleConnectionPoolDataSource which is working fine, but for the Derby client driver it's giving exception as,
org.apache.derby.jdbc.ClientDriver does not have any such attribute loginTimeout.
Looking for your kind responses, please do let me know if there any other way to achieve this as per my requirement or anything I need to add/missing or any information related to this.
Server - Resin 3.0
finally able to achieve this by using c3p0 connection pooling instead of using datasource for derby.C3P0 has checkoutTimeout property which exactly works as per this requirement.

Some queries causes BBDD Closed connection

I have a web app deployed on a Jboss EAP 6 that uses Hibernate to access a SQL Server database.
Every time I look for a specific register I get the error:
com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed
Search for any other register works fine. Restarting JBoss seems to solve the problem. Now I can get the register data without problem.
What could be causing the Exception for that register? Should I focus on the code? On the network? On the datasources definition? On the DB configuration?
There are many reasons, but very offten:
Look at your code, you maybe call close() method
Check out your connection string (NTLMv2?)
Check out MS SQL Server and their setting, DB servers looking for not active sessions and closing them.
Below reasons can be possible
Long query which is hanging up Sql Server.
Using Too much joins in query.
Tables contain more data and you have make the query in which join is not proper.

Number of DB connection using

We are using spring, jpa, hibernate, oracle and java for our web application. While deploying our web application, it uses certain amount of connection from the DB. So i need to find the
following
Total number of available connection
number of connection currently using
number of free connection.
Is it possible? Any help is appreciated. Thanks in advance. When I look in the net, i got the idea of find the above in oracle db as the Admin privileged user. But I need to do it in our application or the external program.
You're using connection pooling so the maximum number of connections is specified in your configuration settings.
Assuming that all the sessions are using a single username and that no other sessions use that same username
select count(*)
from gv$session
where username = <<username your application is using>>
will show you how many sessions are currently open.
I'm not quite sure what it means to you for a connection to be "free" in this context. My guess would be to subtract the number of open sessions from the configured maximum number of sessions but I'm not sure if that's what you're after or not.
use the MyOra tool which has all the key features regarding to DB the developer expect. http://myorasql.com/ and may try with the following oracle query
http://blog.sergkazakov.com/2010/10/check-oracle-number-of-connections.html

Connecting to multiple databases using same JDBC drivers performance

I have a requirement to write a java application (web based) that will connect to an Oracle 11G databases (currently is connecting 10-12 different oracle databases), read some data from it (all are select queries).
After iterating this arraylist, I am connecting each database, fire select query (same query I am firing for all databases), get record , put it in one global collection list and close connection and continuing same process over this loop.
Currently I am "Executors" to connect multiple databases.
again using ExecutorService executor = Executors.newFixedThreadPool(20);
give one surprise to me. for creting first database connection, it shows immediate log, but for subsequent database connection, it prints logs after 60 seconds, so i am not getting why this is taking 60 secs or more for all connections?
logically, it should take time for all connections as like one.
Please suggest performance improvement for this application.
Opening a database connection is an expensive operation; if possible you should connect to each database once and reuse the connection for all queries made to that database (also known as connection pooling). It's not clear if this is what you're already doing.
Another thing that seems strange is that you have made the openConnection method synchronized. I see no need for doing that, and depending on how your code is structured it may mean that only one thread can be opening a connection at a given time. Since connecting takes a long time you'd want each thread to make its connection in parallel.

Can I change the 'appName' on an already open JTDS connection?

I'm looking for a way to pass web-application transaction information on to the underlying database process. In my Java code I might have a transactional method ReservationService#search(), which runs one or several SQLs. On the DBMS I just see a SPID along with some locks. I'm looking for a way to add a tag "ReservationService#search" to the database process.
jTDS / Sybase ASE have an appName which can be passed in as a connection property. As we're using a connection pool, existing connections are re-used, but to my knowledge the appName is only read on establishing a new connection.
How can I re-set the appName on an already existing connection (without closing/opening)? Or, if that simply is impossible, are there any other ideas to get transactional context information from Java to the DBMS?
Tomcat Webapplication (Java 6)
C3P0 Connection Pool (only supports JDBC 3)
jTDS connecting to Sybase ASE 15
Thanks
Simon
Unfortunately not, it seems that you can only specify that in the URL parameters when you open up the connection but can't be altered afterwords.
You can aways pass in a SessionID of some kind from your Java/Tomecat to all your Sybase queries. For me, this was easy as I use stored procedures for all communications between my Java application and the SQL server. I based my SessionID in Java on the J2EE session.

Categories