Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Issues with Oracle connection/statement when accessing through JDBC

 
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.
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • 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.
 
author & internet detective
Posts: 40035
809
Eclipse IDE VI Editor Java
  • 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();
}
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • 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.
 
It's fun to be me, and still legal in 9 states! Wanna see my tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic