aspose file tools*
The moose likes JDBC and the fly likes JDBC session 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 "JDBC session" Watch "JDBC session" New topic
Author

JDBC session

Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Hi,

I have a java POJO to read data from 1 database and update another database. JDBC connection is very expensive.. Any other way to do this ? I mean we are ready to change the design too.

Please suggest this..

Connect to 2 database without closing that we can keep on reuse in a infinite loop.. If so whether the any updation on the database will reflect on the same connection?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Before performing this early optimisation, have you proved it is a problem?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Fine.. Assist me with 1 thing

I have a JDBC connection
1. Am inserting something
2. then after 1 hr am Updating something
3. then after 1 hr am Selecting something
4. closing it.

Whether I will get latest data. Mean someother system may update the same database.

Whether my select will return upto time data
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Nothing to do with whether you keep the connection open and all to do with whether your SQL runs in a transation or not (and what transaction isolation you use).

Though if you are expecting to run three SQL statements over the course of a couple of hours I can't see a performance reason to keep the connection open.
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Paul Sturrock wrote:Nothing to do with whether you keep the connection open and all to do with whether your SQL runs in a transation or not (and what transaction isolation you use).

Though if you are expecting to run three SQL statements over the course of a couple of hours I can't see a performance reason to keep the connection open.


Creating a JDBC connection froma standlone application is very expensive rite.. Thats the reason
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Define "very expensive". If you are only making potentially three connections in as many hours I'd be surprised if you could demonstrate a significant difference in your application's performance if you swapped to using one. (which is why I suggested trying it first).
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JDBC session
 
Similar Threads
Closing connection in JRUN
id of the new field in my table
Query about DSN and DSN less Connection??
Getting connection from pool?
how get connection Id of JDBC connection object