Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2009
    Posts
    10
    Rep Power
    0

    Question How to insert DATE into mysql using JSP?

    I want to insert Date into mysql using JSP,not system DATE, from JSP page.
    Thanks....
    Last edited by sivakumar_sakam; 12-26-2009 at 01:30 PM.

  2. #2
    jogep is offline Member
    Join Date
    Dec 2009
    Location
    Germany
    Posts
    43
    Rep Power
    0

    Default

    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());

  3. #3
    Join Date
    Jan 2009
    Posts
    10
    Rep Power
    0

    Default

    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

  4. #4
    jogep is offline Member
    Join Date
    Dec 2009
    Location
    Germany
    Posts
    43
    Rep Power
    0

    Default

    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

  1. Problem when insert Date to database(SQL)
    By hungleon88 in forum JDBC
    Replies: 6
    Last Post: 04-29-2009, 03:53 PM
  2. Replies: 12
    Last Post: 04-18-2009, 12:58 AM
  3. Replies: 3
    Last Post: 02-28-2009, 09:17 AM
  4. Replies: 5
    Last Post: 10-20-2008, 06:31 AM
  5. Replies: 1
    Last Post: 10-10-2008, 08:47 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •