• 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
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Servlets and JDBC

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, i recently passed SCJP which my company decided to reward by throwing me in the deep end of servlets and JDBC (which is a good thing if a little daunting at first). I have over a years experience in Java with a lot of gui but have not encountered servlets and JDBC before (although i have just started servlets1 on cattledrive which is helping).
The project is a trading system and my little project is to use servlets to access a JDBC database and return the results to a webpage, so for example i can query an entry in a database and get all the details on that entry(replacing a asp page doing a similar thing at present) printed up to a web page.
The project is using Forte Community Edition.
Please could someone give me an indication of any good learning materials, the best way to go about setting myself up etc etc, its a bit over my head at the moment and so i am just ploughing through learning material and playing around to try and get it sorted, or if anyone can help guide me through it if they have the time it would be fantastic.
As it is a test of my strength i am keen to make a great job of it (although the timelimit is quite stretchy) without harassing the resident java guru too much.

Thanks in advance
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sam
There is a good servelet tutorial and also a pretty good one on JDBC topics too.
As far as helping you out that is what we are all here for...
Just post any questions you ahve
 
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd also recomment marty hall's core servlet and javaserver pages, it's a pretty good point to start.
cheers
 
Ranch Hand
Posts: 235
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One good tip I can pass along is to do your Database connections in the init() method of your servlet, as it is expensive on server resources to do on every doGet or doPost request.
Another great resource is Bruce Eckel's "Thinking in Java".
 
Sam Tilley
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys, tips like that are always useful i will check out Marty Hall, is there an equivalent of his sort of help for JDBC???
 
Sam Tilley
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hold on ill ask that question in JDBC so i don't cross thread..
[ May 16, 2002: Message edited by: Sam Tilley ]
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sam,
Please don't forget to add connection pooling to your app
Ex Animo Java!
-- Val
 
author
Posts: 3902
10
Redhat Quarkus Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by John Fontana:
One good tip I can pass along is to do your Database connections in the init() method of your servlet, as it is expensive on server resources to do on every doGet or doPost request.
Another great resource is Bruce Eckel's "Thinking in Java".


Bad idea in modern app servers. Using DataSources (connection pooling) is much faster and less-resource intensive. In fact, doing a "getConnection" from a DataSource at the beginning of your servlet method and then closing it at the end will be significantly faster.
Think about this -- if you get your connections in init() (and presumably store it in a static for each servlet) then each servlet takes up one connection (which is about a Meg of data total). So, if you deploy 100 servlets, you have 100 Meg!
Instead, let the app server do this for you, by using the built-in J2EE connection pooling features.
Kyle
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and check this to get a free class that implements connection pooling, you will need it... .
cheers
 
Sam Tilley
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cheers guys you have given me some great areas to get started with. I have finally gotten my servlets to work on the Tomcat server using web modules (after some playing around). Now i am getting around to connecting up to my database and should hopefully be bringing in my data soon and using your hints hope that i can create quite a good design.
Thanks for all the good links, does anyone have any good tutorials or resources on Forte (apart from the ones on the Sun site). I thought it was quite a big well used IDE but there seems to be little in the way of good resources or info on it outside Sun.
By the way i am putting all of these links on my site www.coggo.com under java resources so that people (and i) can access them quickly. I am still designing it so it looks better (new menu etc etc) but the aim is to have a good resource center for a lot of these different areas of java (for my own use if no-one else uses it). Servlets has its own little area and will be getting added to quite a bit soon i expect along with JDBC.

Thanks
Sam
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic