File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC Connection configuration

 
Rafael Quintana
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody.
I'm having troubles in find the correct way to close my database connection.

I'm using JDCB and access an iseries:

//...
Class.forName("com.ibm.as400.access.AS400JDBCDriver");
Connection micon=DriverManager.getConnection("jdbc:as400://IASO1333;naming=system",
application.getInitParameter(ambiente+"iSeriesUser"),
application.getInitParameter(ambiente+"iSeriesPassword"));
//...

The problem is the idle connections are mantained for about 2 hours!!, i've looking on the iseries server documentation with no results, aslo i looked for the setTimeout() method on the java.sql.Connection class without success.

Please help me these idle-and-still-open connections are laughing on me!

PD

I know the connectionpool is a better aproach to manage connections, but this time is a programmer-pride issue
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33716
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rafael,
Welcome to JavaRanch!

I might be missing the point here, but why don't you just close the connection (in a finally block) when you are done with it. Then it won't be idle.
 
Rafael Quintana
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks so much for your reply.

I've decided to keep the connection open on the same session as it allows me a better control on the database server: on the as/400 the database service which listens on 8471 port, generates a new job for each new connection; that's why i keep the connection alive along the same session.


Thanks again.
 
Tom Blough
Ranch Hand
Posts: 263
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rafael,

If you want to keep the connection open across multiple applications, look into connection pooling. Apache has a great .API for this.

Cheers,
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33716
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rafael,
I know the connectionpool is a better aproach to manage connections

I think you know the answer. Keeping sessions open for long periods of time is dangerous and doesn't scale well. Either way, you really do need a connection pool. Otherwise, you are trading pride for all sorts of undesirable side effects.
 
Rafael Quintana
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok Thanks for the light!

I'll try with connectionPool.

Though i'm still unsatisfied as i was not able to find the setTimeout() method on the Connection class.

Thanks to everybody.
 
Fernando Lescano
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi my friends.. I`m having the same problems, the idle conections to 8471 port in the as400 server are mantained opened for at least 2 hours, even when I used connection.closed(); method to kill them. I�m also using ResultSet object to obtain all the results of my queries.
Each new connection generates a new job which expends server memory and making the as400 slower and slower, as new connections are created.
My question is.. is there any solution to close them without waiting this time?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic