Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Issues with Oracle connection/statement when accessing through JDBC

 
Anks Agarwal
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No we have not tried.
 
Anks Agarwal
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is stateless session bean with container managed transaction.
 
Anks Agarwal
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34410
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anks,
It seems to be a problem with the transaction settings or a table getting locked. Is it always hanging when referencing some table?
 
Anks Agarwal
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic