• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to connect to DB in JSP ?  RSS feed

 
Kishore Sahu
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
tell me the complete procedure to connect to DB in JSP ?
Do I need to import any packages ???
and how to start ?

Thanks
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kishore Sahu wrote:tell me the complete procedure to connect to DB in JSP ?


use DAO . dont put your business logic into jsp . for the steps to connect DB , "google it"
 
Vinoth Thirunavukarasu
Ranch Hand
Posts: 164
Android Java Linux
 
Kishore Sahu
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys..
I got it from google.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vinoth Thirunavukarasu wrote:This link will help you
Terrible. You shouldn't tight couple database logic in a JSP file, let alone write raw Java code in JSP files. It's just receipt for trouble.

Lookup the DAO pattern and make use of it. In fact it is easy: create a DAO class which does all the JDBC task and takes or returns model objects (which are essentially javabeans). It must be able to run standalone as a Java application. Then create a servlet which controls the desired JSP page. Let the servlet use the DAO class to create/read/update/delete data using model objects. In the JSP page you can use JSTL/EL to access the data of the model objects.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vinoth Thirunavukarasu wrote:This link will help you

Follow this link for a good example of how NOT to do it.
 
Kishore Sahu
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyway, Thanks buddies....
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!