Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet & Databases  RSS feed

 
Stefan Elfvinge
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I have a database and regular Javacode that speaks to it, ie. establishing connection and performing SELECT, UPDATE, etc. Not the prettiest code, but it works. Anyway, this is suppused to be a webapp in the end, and the tricky part is now to start writing
servlets and HTML as the final "layers". As always when encountering a new topic- where/how do I START???!!! Write some
HTML first and then "configure" the servlets to it?? Or write servlets first..and what about threads- two users trying to update the same post in a table at the same time. Synchronize all methods that might be called by more than one simultaneously??
Please get me started!!!
 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Consider making the db connection class you already have a simple javaBean and use it in the JSP pages to connect when you want. You might even want one bean for many pages by passing in the SQL string and database table info as parameters - makes more sense.
To protect your data integrity, just synchronise the actual connection methods, that way a page can be opened in multiple clients and they can all try to connect but they'll have to wait in line to do it.
Hope that helps,
Terry
Sorry. Where I said jsp and useBean I had'nt seen you were only talking about servlets & HTML.
Instantiate the beans, pass in the paramaters and call their methods when needed. The synchronisation advice stands.
[This message has been edited by Terence Doyle (edited October 29, 2001).]
 
Stefan Elfvinge
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Terry!
Synchronize only the connection-methods? Maybe I didn't understand what you ment, but what if two or more clients(connected, of course) try to update the same post at the same time, like "UPDATE table xx VALUES(xx, yy)"?
True or false- does a servlet work as a listener between the GUI
and the logic "below"?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!