title: How to connect Oracle Database Using JSP
body: <p>I want to connect my Oracle database with web page using JSP. But data is not saving into database. if you have any idea or the code have any error please comment and show me the way to correct the the following code. Please this is the project of my final semester. 
  The code is as follows. 
  Thanks in advance. </p>
  
  <pre><code>&lt;%@page import="java.sql.*"%&gt;
  &lt;%@page import="oracle.jdbc.driver.*;" %&gt;
  &lt;%@page import="oracle.sql.*;" %&gt;
  &lt;%@page import="oracle.jdbc.driver.OracleDriver;"%&gt;
  &lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Auto Refresh Header Example&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form&gt;
  &lt;center&gt;
  &lt;h1&gt;Program Start&lt;/h1&gt;
  FirstName:&lt;input type ="text" name ="firstName" id="firstName"&gt; &lt;br&gt;
  
  LastName:&lt;input type="text" name ="lastname" id="lastname"&gt; &lt;br&gt;
  
  &lt;input type="submit" value="Submit"&gt;
  &lt;/form&gt;
  &lt;%  
  String username=request.getParameter("username");
  String password =request.getParameter("username");
  
  try {
  
  
  Connection con = null;
  Class.forName("oracle.jdbc.driver.OracleDriver");
  con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "hr", "hr");
  Statement st = null;
  PreparedStatement ps=null;
  ResultSet rs =null;
  String query = "insert into Test (username, username)values           ('"+username+"','"+password+"')";
  
  ps.executeUpdate(query);
  
  } catch(Exception ex){
  
  } 
  
  %&gt;
  &lt;/center&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>