storing date from html form to oracle 10g using servlet

storing date from html form to oracle 10g using servlet

i have following html form from where date,month and year is retrieved separately..

<html>
<form action="./registration.java" method="post">
<select name="DOB_Month">
    <option> - Month - </option><option value="January">January</option>
    <option value="Febuary">Febuary</option><option value="March">March</option>
    <option value="April">April</option><option value="May">May</option>
    <option value="June">June</option><option value="July">July</option>
    <option value="August">August</option><option value="September">September</option>
    <option value="October">October</option><option value="November">November</option>
    <option value="December">December</option>
</select>
<select name="DOB_Day">
<option> - Day - </option><option value="1">1</option><option value="2">2</option>
<option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option>
<option value="9">9</option><option value="10">10</option><option value="11">11</option>
<option value="12">12</option><option value="13">13</option><option value="14">14</option>
<option value="15">15</option><option value="16">16</option><option value="17">17</option>
<option value="18">18</option><option value="19">19</option><option value="20">20</option>
<option value="21">21</option><option value="22">22</option><option value="23">23</option>
<option value="24">24</option><option value="25">25</option><option value="26">26</option>
<option value="27">27</option><option value="28">28</option><option value="29">29</option>
<option value="30">30</option><option value="31">31</option>
</select>
<select name="DOB_Year"><option> - Year - </option>
<option value="2004">2004</option><option value="2003">2003</option>
<option value="2002">2002</option><option value="2001">2001</option>
<option value="2000">2000</option><option value="1999">1999</option>
<option value="1998">1998</option><option value="1997">1997</option>
<option value="1996">1996</option><option value="1995">1995</option>
<option value="1994">1994</option><option value="1993">1993</option>
<option value="1992">1992</option><option value="1991">1991</option>
<option value="1990">1990</option><option value="1989">1989</option>
<option value="1988">1988</option><option value="1987">1987</option>
<option value="1986">1986</option><option value="1985">1985</option>
<option value="1984">1984</option><option value="1983">1983</option>
<option value="1982">1982</option><option value="1981">1981</option>
<option value="1980">1980</option><option value="1979">1979</option>
<input type="submit" name="sub" id="sub"/>
</select>
</form>
</Html>

i want to insert this date month year from html form into oracle 10g database where i have a table named "details" and column name "dob" of "date" type...for this i have created a "registration.java" servlet..coding is as follows:

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.*; 
public class registration extends HttpServlet {
    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        Connection con=null;
        Statement st=null;
        ResultSet rs=null;
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","ORS","ors");

 // code for inserting date into oracle 10g in the format of oracle


        } catch(ClassNotFoundException c)
        {
            System.out.println(c);
        }
        catch(SQLException se)
        {
            System.out.println(se);
        }
        finally {
            try{
           rs.close();
            st.close();
           con.close();
            }catch(SQLException se)
            {
                System.out.println(se);
            }
            }
            }

Note: i have mentioned here only necessary coding..not mentioned here my full html form and servlet coding.... i don't know what should be the coding for inserting date in oracle's format..if der is ny1 to help me for the code of inserting date..i have tried a lot to find on google..but was not able to get the solution..so finally hv decided to post here...plz help me thnx in advance.....:):)

View Answers

April 6, 2012 at 9:22 AM

to insert the data in oracle you need to follow the jdbc concept. here is the snippet of an example: public class ConnJha {

Connection  con;
Statement   st;
ResultSet rs;
 PreparedStatement pt;

public ConnJha()
{

    connect();
}

public void connect(){

    try{

    String driver = "oracle.jdbc.OracleDriver";
    Class.forName(driver);

    con = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:XE","username","password");
    st = con.createStatement();

    String sql1 = "INSERT INTO <table_name>" +
            "VALUES ('value1', 'value2', 'value3', 'value4')";
    st.executeUpdate(sql1);



        }
        catch(Exception e){
            e.printStackTrace();

        }

}

}









Related Tutorials/Questions & Answers:
storing date from html form to oracle 10g using servlet
storing date from html form to oracle 10g using servlet  i have following html form from where date,month and year is retrieved separately.. <... this date month year from html form into oracle 10g database where i have
storing date from html form to oracle 10g using servlet
storing date from html form to oracle 10g using servlet  i have following html form from where date,month and year is retrieved separately.. <... this date month year from html form into oracle 10g database where i have
Advertisements
Uploading file in servlet from a html form
Uploading file in servlet from a html form  Sir, I want to upload a picture from my html file and save it to my database as BLOB,but what JAR should... this process without using a third party JAR, just using Java API. please help
calling java method from html form with out using javascript - JSP-Servlet
calling java method from html form with out using javascript  How can i call java method from a HTML form, java script should be disabled?  ...;script LANGUAGE="JavaScript">function testResults(form
Insert or retrieve image into oracle 10g by using java
Insert or retrieve image into oracle 10g by using java   How can i insert or retrieve image into oracle10g using java plz i need it urgently,need guidance to do this plz
Retrieve database from the table dynamically in jsp from oracle using servlet
Retrieve database from the table dynamically in jsp from oracle using servlet  Sir, I have created a table in oracle using eclipse, and added few... using java servlet from the database in the jsp page
fetch record from oracle database using jsp-servlet?
fetch record from oracle database using jsp-servlet?  how can i fetch data from oracle database by using jsp-servlet. i'm using eclipse, tomcat server and oracle database and creating jsp pages and also using servlet
How to create a databas locally in our system using Oracle 10g????
How to create a databas locally in our system using Oracle 10g????  How to create a databas locally in our system using Oracle 10g
how to load values of html form into an excel table using java servlet?
how to load values of html form into an excel table using java servlet?   i have written a java servlet program, which has a html form to be filled. after filling the form the servlet generates a receipt and the values should
error in uploading image from jsp to oracle 10g database
error in uploading image from jsp to oracle 10g database  ...;TITLE>Display file upload form to the user</TITLE></HEAD> <BODY> <FORM ENCTYPE="multipart/form-data" ACTION="upload.jsp" METHOD=POST>
i need a school appication using struts frame work with oracle 10g using myeclipse6.0
i need a school appication using struts frame work with oracle 10g using myeclipse6.0   hi i need a school apllication using struts frame work backend 10g xe using myeclipse 6.0
html form - JSP-Servlet
html form  how to retrieve database value in dropdown list box placed in html form  Hi friend, Visit for more information. http://www.roseindia.net/jsp/ Thanks
Html form validation using jquery
Html form validation using jquery  Hi i am using form with html. Form elements like textbox, radio,checkbox,listbox i was used now how to validate the elements using submit jquery option
data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp
data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp   data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp with script of data base plz help me
tables in oracle 10g
tables in oracle 10g  sir i have created a table in oracle 10g,i want to know where this table is stored and how can i move this table to another pc and insert values
i am getting the problem when i am downloading the pdf file from oracle 10g database - Struts
i am getting the problem when i am downloading the pdf file from oracle 10g database  if i created the pdf file from pdf machine,it is storing into datbase and download the pdf file from database. but when i created the pdf file
instruction to install oracle 10g in linux....
instruction to install oracle 10g in linux....  how to install oracle 10g in linux
HTML form validation using jquery
HTML form validation using jquery  Is there any way for validating html elements common under a class by giving its class name in jquery validation code..that means validating all elements by using its class name if those
Sending form data from HTML page to SQLserver 2005 database by calling servlet code
Sending form data from HTML page to SQLserver 2005 database by calling servlet code  Hi sir, I would like to know how to send the form data from html page to database by calling servlet code from html page .   
storing csv into oracle database
storing csv into oracle database  i want jsp code for storing csv file into oracle database
android connection to database oracle 10g
android connection to database oracle 10g  Hello, How i can connect my android application to my oracle 10g database
How to get the data from the database (Oracle) in console or in ie using servlet or jsp as Front end
How to get the data from the database (Oracle) in console or in ie using servlet or jsp as Front end  hello i have a simple problem in jsp in the sense to get data from the database like oracle . I have created one jsp
Upload csv or .xlsx file from JSP form to Database Table using servlet
Upload csv or .xlsx file from JSP form to Database Table using servlet  dear sir, i need the Servlet code that reads the .xlsx or CSV excel file and stores it into the oracle database table. Sir Its very Urgent I have
JSP:HTML Form in-place Editing - JSP-Servlet
JSP:HTML Form in-place Editing  I have an HTML form (form #1) which... of a customer search in a small table on the same page using another servlet(also working... from a stringquery into another page and having the same form, for some reason
Tomcat not supporting Oracle 10g - WebSevices
Tomcat not supporting Oracle 10g  While Starting my Tomcat Server am... of Oracle version(Oracle 8i to Oracle10g). SEVERE: End event threw exception... time=16/47 config=C:\Tomcat 4.1\bin\..\conf\jk2.properties
example of 1700 bir form using html
example of 1700 bir form using html   example of 1700 bir form using html i don't know how to start it... i'm confused on what would i do first and what would i use... :( please help me on this.... thank you in advance
Html form using JavaScript to display the table content
Html form using JavaScript to display the table content  HI There, Greetings, I am new to this java and I need your assistance. I have created... want to write a Html JavaScript coding to display the content from database
Using a image for Browse button instead of normal html Browse button for Uploading files from a JSP - JSP-Servlet
Using a image for Browse button instead of normal html Browse button for Uploading files from a JSP  I am using the following code snippet.... Is it not possible to use a image instead of normal html Browse button for uploading files
JSP:HTML Form in-place Editing - JSP-Servlet
JSP:HTML Form in-place Editing  Hi, I want to thank the people... developer's needs. This is a follow up to the HTML Form in-place editing. The code... an excellent way of editing a form. I just have a few adjustments if any of you could
how to retrieve text and images from mysql database and show on html page using jsp servlet
how to retrieve text and images from mysql database and show on html page using jsp servlet  <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> Insert title here h3
JSP to add details to a database from a HTML form.
JSP to add details to a database from a HTML form.  Hi I'm a second year CS student who has to use JSP to validate a HTML form and add the details... from form and stores it in User--%> String Pword = request.getParameter
how to update values of a html form into an excel table using java servlets?
how to update values of a html form into an excel table using java servlets?  i have written a java servlet program, which has a html form to be filled. after filling the form the servlet generates a receipt and the values should
Oracle 10g Express Edition - IDE Questions
Oracle 10g Express Edition  Do we need internet connection to work with oracle10g Express Edition
how to write a jsp form using html
how to write a jsp form using html  hi, i have written the code as below... but it is showing error. please help me how to resolve it. .html file...; <body> <form method="POST" action="Form1.jsp"> EmployeeNo: <
jsp or sevlet and html form to send picture to database - JSP-Servlet
that contains his picture to database. What I need are html page for the form that will browse for the picture, jsp or servlet that the info from html will go...jsp or sevlet and html form to send picture to database  Hello guys
how to store image in oracle express edition using servlet
how to store image in oracle express edition using servlet  strong text how to store image in oracle express edition using servlet?   Please visit the following link: Servlet Insert image into MySQL database
HTML code to servlet to database using jdbc
HTML code to servlet to database using jdbc  pls send me the code..._TO_REPLACE_1 1)form.html: <html> <form method="post" action="http://localhost... { String msg=req.getParameter("msg"); res.setContentType("text/html
How to delete the row from the Database by using servlet
: Delete row from database using servlet   In that link solution...How to delete the row from the Database by using servlet  Dear Sir... by using servlet program (Tomcat server). The given data is true
How to retrieve array values from html form to jsp?
How to retrieve array values from html form to jsp?  Hi! I am... it into jsp. Means i just want to retrieve values from html form containing array..., To get an array values from the html form you can use the getParameterValues
Data fetching from JSP or HTML - JSP-Servlet
Data fetching from JSP or HTML  Hi Deepak, Can u pls help me as i have a problem with jsp/html frameset. my question is how can i fetch the data from frameset which is in html format.pls help me. Thanks
get info from mysql using jsp and servlet
the user to key in their email address from mysql database by using servlet and jsp too...get info from mysql using jsp and servlet  HELLO! I wanna create... retrieved from database. 1)search.jsp: <html> <head> </head> <
how to load a table of data from oracle, to a jsp page using hashmap.
how to load a table of data from oracle, to a jsp page using hashmap.  I have a jsp page which ask for project ID,team name,member name according to this data i have to retrieve their details from the database(oracle). I have
how to generate reports from oracle database using jsp and ajax code
how to generate reports from oracle database using jsp and ajax code  Hai masters i am new to this Java world. my team leader ask me to generate sales report data from oracle database to jsp page please any one know how to do
login and registration form using servlet and authentication through mysql
login and registration form using servlet and authentication through mysql  i made a simple login and rgistration form using servlet... (signup form) <%@page contentType="text/html" pageEncoding="UTF-8"%>
what is difference b/w oracle 8i, 9i and 10g
what is difference b/w oracle 8i, 9i and 10g  what are the difference between oracle 8i,9i and 10g? I am not considering the versions and their supported os, in the interview point of view
Error in Storing date - Development process
Error in Storing date  Hi, U have given this code for storing date..., MS Access Database sets the date in DD/MM/YYYY format. Take field id of text type and date of date/time type.Then try the following code: Thanks
How to get data from Oracle database using JSP
How to get data from Oracle database using JSP  hello i have a simple problem in jsp in the sense to get data from the database like oracle . I have... the answer to retrieve data from the database by using servlet or jsp program
how to read data from excel file through browse and insert into oracle database using jsp or oracle???
how to read data from excel file through browse and insert into oracle database using jsp or oracle???  sir.. i have number of excel sheets which... be inserted into oracle database.. please help me sir...   hi friend
call json object using url and represent in html tabular form
call json object using url and represent in html tabular form  how to call json object using url from html and represent in proper format it gives Json object after that i want to arrange the keys-values in table
call json object using url and represent in html tabular form
call json object using url and represent in html tabular form  how to call json object using url from html and represent in proper format it gives Json object after that i want to arrange the keys-values in table

Ads