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:
Advertisements
Uploading file in servlet from a html formUploading 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
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 html form - JSP-Servlethtml 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 jqueryHtml 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
tables in oracle 10gtables 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
HTML form validation using jqueryHTML 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
JSP:HTML Form in-place Editing - JSP-ServletJSP:
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 - WebSevicesTomcat 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 contentHtml 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
JSP:HTML Form in-place Editing - JSP-ServletJSP:
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
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 write a jsp form using htmlhow 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:
<
HTML code to servlet to database using jdbcHTML 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 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-ServletData 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>
<
what is difference b/w oracle 8i, 9i and 10gwhat 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 processError 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 JSPHow 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