Results 1 to 4 of 4
- 12-26-2009, 12:26 PM #1
Member
- Join Date
- Jan 2009
- Posts
- 10
- Rep Power
- 0
- 12-26-2009, 05:57 PM #2
Member
- Join Date
- Dec 2009
- Location
- Germany
- Posts
- 43
- Rep Power
- 0
You can use the setDate Function of PreparedStatement to set a Date.
Following Example set the current Date, but you can use any Date Object.
Java Code:String INSERT = "insert into mydatetable(id, datecolumn) values(?, ?)"; PreparedStatement ps = conn.prepareStatement(INSERT); ps.setLong(1, 1L); ps.setDate(2, new Date());
- 12-27-2009, 02:15 AM #3
Member
- Join Date
- Jan 2009
- Posts
- 10
- Rep Power
- 0
thanks sir for reply.
In the above example new Date() is system Date, but i want to insert Date enter by the Client from the JSP page.
thnks
- 12-27-2009, 07:52 PM #4
Member
- Join Date
- Dec 2009
- Location
- Germany
- Posts
- 43
- Rep Power
- 0
If you work without an framework the parameters are in the HttpRequest Object as String.
You can parse the parameter values with DateFormat.
Just Google for SimpleDateFormat for sample how to parse a String to Date.
Similar Threads
-
Problem when insert Date to database(SQL)
By hungleon88 in forum JDBCReplies: 6Last Post: 04-29-2009, 03:53 PM -
Is there a way to have mySQL auto fill in the current date into my dateCreated field?
By Md Saim in forum JDBCReplies: 12Last Post: 04-18-2009, 12:58 AM -
How to insert large data into database using one insert query
By sandeepsai39 in forum New To JavaReplies: 3Last Post: 02-28-2009, 09:17 AM -
java.lang.NullPointerException in MySQL INSERT
By int80 in forum JDBCReplies: 5Last Post: 10-20-2008, 06:31 AM -
how to insert date field read from Excel using JExcel to database
By saran123 in forum JDBCReplies: 1Last Post: 10-10-2008, 08:47 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks