• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet+Database connectivity

 
Sai P Kumar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I would like to know the best way to connect to the database from Servlet and perform the standart query on the database?
I would appreciate any help regarding this issue.
Thank you.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way you should connect with a database from a servlet i sthe same as you should from just about any Java program :- using the JDBC (Java Database Connectivity API) API.
WIth that in mind, I'v emoved this post over to our JDBC forum, where you will probably get more useful answers.
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using java DataSources is the standard way. I have a generic DataAccess class available as part of the FormattedDataSet that abstracts using standard jdbc connections and DataSource connections, so your code will work the same in both cases.
The DataAccess classes are also monitored for performance and come with a method that converts ResultSets to Object[][] (wrapped in the ResultSetConverter object). This approach allows my code to make all your jdbc calls (i.e. opening, closing connections, statements, ResultSets).
A live demo and javadocs are available at http://www.fdsapi.com. In the javadocs look at DataAccess, DataAccessBase, DataAccessClient, and DataAccessJ2EE.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic