How do you connect to the database from JSP

Showing Answers 1 - 12 of 12 Answers

Kasthuri Aravamudhan

  • Jun 17th, 2005
 

To be precise to connect jdbc from jsp is not good idea ofcourse if ur working on dummy projects connecting to msaccess u can very well use the same connection objects amd methods in ur scriplets and define ur connection object in init() method. 
 
But if its real time u can use DAO design patterns which is widely used. for ex u write all ur connection object and and sql quires in a defiened method later use transfer object [TO ]which is all ur fields have get/set methods and call it in business object[BO] so DAO is accessd with precaution as it is the crucial. Finally u define java bean which is a class holding get/set method implementing serialization thus the bean is called in the jsp. So never connect to jdbc directly from client side since it can be hacked by any one to get ur password or credit card info.

d.anand

  • Jun 28th, 2005
 

good

  Was this answer useful?  Yes

sumithra sen

  • Jul 31st, 2005
 

well done, this is what I need

  Was this answer useful?  Yes

veni

  • Sep 26th, 2005
 

using tag libraries with attributes as username and password

  Was this answer useful?  Yes

swapna

  • Oct 15th, 2005
 

using JDBC-ODBC connection

  Was this answer useful?  Yes

chaitanya

  • Jan 13th, 2006
 

it is the code for connecting jsp with database<%Class.forName("oracle.jdbc.driver.OracleDriver");Connection con=DriverManager.getConnection("jdbc:oracle:thin:@server:1521:dsn","scott","tiger");Statement stmt=con.createStatement(); %>

  Was this answer useful?  Yes

rajasekhar

  • Feb 20th, 2006
 

Hi,I saw ur answer for this question,but I want clear explanation ,so please  send the code for this explanation means DAO,TO,BO.

Plzplzpzlzplz......

  Was this answer useful?  Yes

tillu

  • Feb 23rd, 2006
 

 very good answer,

  Was this answer useful?  Yes

bora_srinivasarao

  • Mar 7th, 2006
 

hi friends,By using sql tag libraries of jstl and sql-rt tag libraries of jstl we can connect database.we can provide the code in jsp by usin sql , query custom tags and setDatasource attributeand also for making flexiblity we can provide the driver class name and url ,password,username as init params in the web.xmlokey bayeee... if there is any questins on j2se,jdbc,servlets,jsp,jndi,java mail api,java bean , plz send that to my mailid given below------>bora_srinivasarao@yahoo.co.inoky bayeeee.................. keeps smiling and mailing bora_srinivasarao@yahoo.co.in

  Was this answer useful?  Yes

mahathi

  • Oct 11th, 2006
 

really good answer

  Was this answer useful?  Yes

swapnilk

  • May 15th, 2008
 

BO stands for Busssiness Object where you are going to do all kind of logical calculations.
DAO stands for Data Access Object where you are communicating with DataBase by firing qry
DTO stands for Data Transfer Object where if u want to retrieve or send data to data base this object will come into picture and you can work on this object.
Majorly this object is useful for them who is not aware with DB and qry's and other stuff. As a java programmer they can work on java.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions