❮ Previous Next ❯

Retrieve Data from Oracle database using JSP

Here in this context we have a database and the database contain some data. We will develop a JSP application and when it will execute, we will retrieve the data from database.
Let we have a student table containing some records.
Friends, before going to the development, first we have to know we are using Oracle10g / 11g XE database and we are using Eclipse environment and our server is web server that is Apache Tomcat9.0
Step-1: First in Oracle environment we will create a Student Table:
create table Student
sregdno varchar2(200),
sname varchar2(200),
saddress varchar2(200)
Table created.

Now we inserted 3 records and the output like:

Jsp Retrieve data

Step-2: Now we will go to eclipse environment and we will develop 2 JSP files, like index.jsp and retrieve.jsp

Required Files:
<form action="retrieve.jsp">
            Please enter the regdno:
            <INPUT TYPE="TEXT" NAME="regdno">
            <INPUT TYPE="SUBMIT" value="Submit">

<%@ page import="java.sql.*" %>

Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "system", "oracle");

Statement st = con.createStatement();

String id = request.getParameter("regdno"); 

ResultSet rs = st.executeQuery("select * from Student where sregdno = '" + id + "'") ;

if(!rs.next()) {
                out.println("Sorry, could not find therecord. ");
            } else {

        <TABLE BORDER="1">
               <TD> <%= rs.getString(1) %> </TD>
               <TD> <%= rs.getString(2) %> </TD>
               <TD> <%= rs.getString(3) %> </TD>


jsp dataretrieve
❮ Previous Next ❯

Follow Us


Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Email: info@silantechnology.com
      Phone: 0674-2361252
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved