Java Servlet Database Connectivity with Oracle Express Edition

Java Servlet Database Connectivity with Oracle Express Edition

Prerequisites to Execute Database Connectivity:

1)      Download Jar and save to lib folder of Apache  (ojdbc14-1.0.jar Required): Download Here

2)      Update Classpath to following (Path in Bold are new):

C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\servlet-api.jar;C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\jsp-api.jar;C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\ojdbc14-1.0.jar;.

3)      Download and Install Oracle Express Edition.

First Create Your Database and Tables

Table Name: student

FieldName

Type

sid number(10) Primary Key
sname varchar2(20)

 

Query for Table:

Hello JDBC using Servlet Example

FilePath : C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\example02\WEB-INF\classes

FileName: ex02.java

 Hello JDBC using Servlet Example Explanation:

Line : Class.forName(“oracle.jdbc.driver.OracleDriver”);

Explanation : This Line if toload Driver for Oracle Database Connectivity with Java Servlet.

 

Line: Connection con = DriverManager.getConnection (“jdbc:oracle:thin:@localhost:1521:XE” ,  “adarsh”, “patel”);

Explanation : This Line is most important as it contains userid and password of Oracle Express Edition. Here I have used userid : adarsh and password : patel. Only 2 Fields you need to change is userid and password.

 

FilePath : C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\example02\WEB-INF\

FileName: web.xml

 

FilePath : C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\example02\

FileName: index.jsp

Output

 Java Servlet Database Connectivity with Oracle Express Edition

Adarsh Patel

My Self Adarsh Suryakant Patel. Currently I am working as Assistant Professor at Parul Instiute of Engineering and Technology, MCA Department, Limda, Vadodara. Major Responsibility : * Lectures * Organizing Training and Expert Sessions for * Placement and Recruitment * Faculty Representative