This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Issues with Oracle connection/statement when accessing through JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Issues with Oracle connection/statement when accessing through JDBC" Watch "Issues with Oracle connection/statement when accessing through JDBC" New topic
Author

Issues with Oracle connection/statement when accessing through JDBC

Anks Agarwal
Greenhorn

Joined: Jul 22, 2004
Posts: 5
We are having application in java which run for more than 1 hour.
We are using stateless CMP bean.Oracle is the Database.
We are having lot of database hits and the connection pooling is used.We are closing all the statements/prepared statements.
All the connections are closed after firing the queries.
The application hangs after some time.The Web server does not respond to any request after that.
Any pointers will be helpful.
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1121

Anks,

We are using stateless CMP bean

As far as I know, there is no such thing.

Any pointers will be helpful

Have you tried profiling or debugging your application, to see where it is getting stuck?

Good Luck,
Avi.
Anks Agarwal
Greenhorn

Joined: Jul 22, 2004
Posts: 5
No we have not tried.
Anks Agarwal
Greenhorn

Joined: Jul 22, 2004
Posts: 5
That is stateless session bean with container managed transaction.
Anks Agarwal
Greenhorn

Joined: Jul 22, 2004
Posts: 5
We debugged the application and its not at unique place where it hangs..But one thing I noticed is if the application hangs and if we run it again.it hangs sooner.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

Anks,
It seems to be a problem with the transaction settings or a table getting locked. Is it always hanging when referencing some table?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Anks Agarwal
Greenhorn

Joined: Jul 22, 2004
Posts: 5
What really bothers me is that in my Web application,I am running a simple program in which I am just opening a connection,statement,getting a resultset and closing the resultset,statement and connection.But I am doing all this in loop which may run up to 40000...The Web Sever hangs...The SQL query is Select query so no chance of table getting locked.
for(int i=0;i<=20000;i++){
System.out.println("test1_2 i =" + i);
Object obj = Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
DriverManager.registerDriver((java.sql.Driver)obj);
con = DriverManager.getConnection(URL, USERNAME, PASSWORD);
Stmt = con.createStatement();
rs = Stmt.executeQuery(sb.toString());
if (rs.next())
{
}
rs.close();
Stmt.close();
con.close();
}
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Why do you create 20.000 / 40.000 connections?
Is this a stress-test?

And why do you use:


all you need is:

The driver get's registered while loading behind the scene.

You need to load the driver only once.
If url, username and password don't differ, you need only one connection.
If the statement only differs in a detail, you should use a prepared statement.


http://home.arcor.de/hirnstrom/bewerbung
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Issues with Oracle connection/statement when accessing through JDBC
 
Similar Threads
Why do developers not use a class having list for all drivers?
Configuring org.apache.commons.pool.impl.GenericObjectPool
problem in getting the database connection from a connection pool
how to define a transaction in servlets?
Connection pool + performance