• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

DAO pattern for JDBC code?

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my desktop project, I am using JDBC. I need to get data from database in aroud all the methods, so I doing the follwing in all those methods: loading class, making connection, getting data, closing connection.

Now the problem is, my project performance is very poor. It is very slow while execution.

What can I do to avoid this situation?

Ilja has suggested to use DAO pattern.

Please give me some details, how it can help? and very importantly how much changes I have to do in code because I have JDBC code in around all the methods...

Thanks.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Data Access Object. You may also want to see Transfer Object/ Value Object.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey you have got the example Data Access Object example app.

Cheers.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DAO for sure will help you to organize your code.

For the performance problem you will need first to identify where is the bottleneck of your system, or the piece of code making it slow. Is it the SQL queries? The UI Swing code? Start printing the times of execution of some methods and find out.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Fabio Lin:
DAO for sure will help you to organize your code.

For the performance problem you will need first to identify where is the bottleneck of your system, or the piece of code making it slow. Is it the SQL queries? The UI Swing code? Start printing the times of execution of some methods and find out.



It is SQL code, where I can definitely do something because it is very bad written. But not clear how should I do?

Please any body suggest...

Thanks a lot.

 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about singleton pattern. I will have only one instance of connection at any time...

Please comments.

Thanks.
 
reply
    Bookmark Topic Watch Topic
  • New Topic