Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC session

 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before performing this early optimisation, have you proved it is a problem?
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic