Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java Databases
|
Java Databases Discussion specific to working with Java Databases. For other Java topics, please see related Java forums. For database discussions not specific to Java, please see the Database category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 24th, 2004, 12:33 PM
Authorized User
 
Join Date: Oct 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem in prepared Statement

hi,
I have a jsp page

i have used following prepared Statement for the update in database.

Can any one tell me that,How can i use date in following method.

I have 4 field for date as given below:(BOLD shown)

I have used String in that place.

It is not working.




PreparedStatement pstatement = conn.prepareStatement(
"UPDATE sec_mast SET catg_code=?, vou_no=?, vou_date=?, vou_amt=?, due_date1=?, due_date2=?, mat_date=? where sec_no=? ");

pstatement.setInt(1,Integer.parseInt(request.getPa rameter("catg_code")));
pstatement.setString(2,request.getParameter("vou_n o"));
pstatement.setString(3,request.getParameter("vou_d ate"));
pstatement.setInt(4,Integer.parseInt(request.getPa rameter("vou_amt")));
pstatement.setString(5,request.getParameter("due_d ate1"));
pstatement.setString(6,request.getParameter("due_d ate2"));
pstatement.setString(7,request.getParameter("mat_d ate"));
pstatement.setInt(8,Integer.parseInt(request.getPa rameter("sec_no")));


int rowCount = pstatement.executeUpdate();
conn.setAutoCommit(false);
conn.setAutoCommit(true);
}

plz help me

 
Old February 11th, 2005, 08:28 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 345
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to gokul_blr Send a message via Yahoo to gokul_blr
Default

Check your Data type conversion like java.sql.Date & Date

Gokulan Ethiraj
 
Old March 23rd, 2006, 09:34 AM
Authorized User
 
Join Date: Mar 2006
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

U can set date by using this method :-
void setDate(int parameterIndex, Date x)
Sets the designated parameter to the given java.sql.Date value.

Have a look on this URL for more details on java.sql.PreparedStatement :-
http://java.sun.com/j2se/1.4.2/docs/...Statement.html






Similar Threads
Thread Thread Starter Forum Replies Last Post
prepared statement sanqry J2EE 0 April 16th, 2006 02:58 AM
Prepared SQL VS. Regular Queries nikotromus Pro VB 6 0 January 17th, 2006 08:37 PM
Prepared SQL VS. Regular Queries nikotromus Access VBA 2 January 14th, 2006 06:56 PM
problem in prepared statement abhit_kumar JSP Basics 1 November 25th, 2004 04:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.