Java Development
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Remember me

Go Back   Dev Articles Community ForumsProgrammingJava Development

Add This Thread To:   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
Unread Dev Articles Community Forums Sponsor:
Old December 3rd, 2004, 03:47 AM
abhit_kumar abhit_kumar is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
Join Date: Nov 2004
Posts: 22 abhit_kumar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 3 sec
Reputation Power: 0
insertion prob of date using prepared stmt


i have a jsp page which is used for the insertion of values in oracle database.
MY problem is that it can insert the date in only dd-MMM-yy format and display the date in yyyy-mm-dd format.

I want that i can enter the date in dd/mm/yyyy format and display it on dd-MMM-yy format.

Plz help me.. i get stuck in this..

My code is as follow:

<%@ page import =" java.sql.Date.*" %>
<%@ page import =" java.text.SimpleDateFormat.*" %>
<%@ page import =" java.util.Date.*" %>
<%@ page import =" java.text.*" %>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page language="java" import="java.sql.*" %>

try {
Connection conn=DriverManager.getConnection("jdbcdbcf","scott","ttlscott");
System.out.println("got connection");
String action = request.getParameter("action");
if (action != null && action.equals("save")) {
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yy");

PreparedStatement pstmt = conn.prepareStatement(
("INSERT INTO pay_header VALUES (?, ?, ?, ?, ?, ?,?,?)"));

pstmt.setString(5, request.getParameter("chq_no"));
pstmt.setFloat(7,Float.parseFloat(request.getParam eter("chq_amt")));



Statement statement = conn.createStatement();

ResultSet rs = statement.executeQuery
("SELECT * FROM pay_header ");

<th>Dr. Amt</th>
<th>Cr. Amt</th>
<form action="payment_save1.jsp" method="get">
<input type="hidden" value="save" name="action">
<th><input value="<%= request.getParameter("voucherno") %>" name="vou_no" size="10"></th>
<th><input value="<%= request.getParameter("date") %>" name="pay_date" size="10"></th>
<th><input value="<%= request.getParameter("hold") %>" name="pay_post" size="15"></th>
<th><input value="<%= request.getParameter("narration") %>" name="pay_narr" size="15"></th>
<th><input value="<%= request.getParameter("chqno") %>" name="chq_no" size="15"></th>
<th><input value="<%= request.getParameter("chqdate") %>" name="chq_date" size="15"></th>
<th><input value="<%= request.getParameter("chqamt") %>" name="chq_amt" size="15"></th>
<th><input value="<%= request.getParameter("post") %>" name="pay_type" size="15"></th>
<th><input type="submit" value="save"></th>
while ( ) {

<form action="payment_save1.jsp" method="get">
<input type="hidden" value="save" name="action">
<td><input value="<%= rs.getString("vou_no") %>" name="vou_no"></td>
<td><input value="<%= rs.getDate("pay_date") %>" name="gl_descr"></td>
<td><input value="<%= rs.getString("pay_post") %>" name="pay_post"></td>
<td><input value="<%= rs.getString("pay_narr") %>" name="pay_narr"></td>
<td><input value="<%= rs.getString("chq_no") %>" name="chq_no"></td>
<td><input value="<%= rs.getDate("chq_date") %>" name="chq_date"></td>
<td><input value="<%= rs.getFloat("chq_amt") %>" name="chq_amt"></td>
<td><input value="<%= rs.getString("pay_type") %>" name="pay_type"></td>

<td><input type="submit" value="save"></td>


// Close the ResultSet
// Close the Statement
// Close the Connection
} catch (SQLException sqle) {
} catch (Exception e) {

Reply With Quote

Viewing: Dev Articles Community ForumsProgrammingJava Development > insertion prob of date using prepared stmt

Developer Shed Advertisers and Affiliates

Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.

© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap