aspose file tools*
The moose likes JDBC and the fly likes java code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java code " Watch "java code " New topic
Author

java code

prabhu kandanur
Ranch Hand

Joined: Oct 18, 2003
Posts: 34
hi
i wanted to list out list of java classes, where the connection/preparedstatement open. Is there any readymade java code/tool available to check in the DAO package.

Thanks inadvance
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


i wanted to list out list of java classes, where the connection/preparedstatement open

classes? Do you mean instances, or are you only looking for a way to parse classes and find out where a JDBC connection may be opened?

(Please, UseAMeaningfulSubjectLine in future. Thanks )


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
prabhu kandanur
Ranch Hand

Joined: Oct 18, 2003
Posts: 34
sorry for that,
i wanted to list all java classes in a package, where connection is opened but not closed. i wanted to get those java classes list.
thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18114
    
    8

You could perhaps use javap to disassemble the classes. This might enable you to find classes where the Connection.close method was not called. But just because a class contains a call to Connection.close, that doesn't mean the call is actually executed reliably and correctly at run time. There isn't any automated way to determine that.

So you might be better off just doing a source-code search to identify the classes where connections are created, then have a person look at each of those classes.
Vinod K Singh
Ranch Hand

Joined: Sep 30, 2008
Posts: 198
Opening and closing connection in each class is a bad idea as it will lead to degraded performance.

To find the connection not closed do text search on your code.


My Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java code
 
Similar Threads
How to print the elements of an arraylist that contains a hashmap
forEach tag
How to convert value to lowercase in ant
Split String to ArrayList
SCJP 6 question