Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how to connect the back end with Directive tag in jsp ...



how to connect the back end with Directive tag in jsp .....

Answer / lovly

A Connection to a database can be established from a jsp page by writing the code to establish a connection using a jsp scriptlets.


<%@ page language=”java” contentType=”text/html”
import=”java.sql.*,java.sql.Statement %>

<%
//load the Oracle JDBC driver or any other driver for a specific
vendor
Class.forName(”sun.jdbc.odbc.JdbcOdbcDriver”);

//open a connection to the “scott” database or other database which you have created. You should provide the username and password as part of this connection string. Here the username and password are scott and tiger.
Connection con=
DriverManager.getConnection(”jdbc:odbc:scott”,”scott”,”tiger”);

//create a statement object for sending SQL queries
Statement stmt = con.createStatement();

//place query results in a ResultSet object

//To get all projects of a particular project leader.
ResultSet res = stmt.executeQuery(” select * from employee”);

String ename=null;

%>
Further then you can use the resultset object “res” to read data in the following way.



<%
while(res.next())
{
ename=res.getString(”ename”);
%>

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More JSP Interview Questions

Can a constructor be used in place of init() method to initialize a servlet?

0 Answers  


What is jsp application?

0 Answers  


Is jsp and javascript same?

0 Answers  


Give a sample jsp configuration in the deployment descriptor.

0 Answers  


How can the applets be displayed in the jsp? Explain with an example.

0 Answers  


How can we avoid direct access of jsp pages from client browser?

0 Answers  


Which one is better jsp or servlet?

0 Answers  


What is jsp tag?

0 Answers  


How can html output be prevented from being cached?

0 Answers  


Explain the various scope values for <jsp:useBean> tag.

0 Answers  


What is the difference between directive include and jsp include?

0 Answers  


Can we use javascript in jsp?

0 Answers  


Categories