Inserting Date into Ms- Access Using jsp

Discussion in 'JSP' started by sriram225, Jun 1, 2009.

  1. sriram225

    sriram225 New Member

    Joined:
    May 22, 2009
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    hai frnds,
    my Table (named as Services) in Ms -Access database contains Following fields...
    Code:
    num ----------"AUTONUMBER"
    name---------"Text"
    date----------"Date/Time"
    And

    I am inserting data into this table.........
    I am Taking name value from an html input page and my jsp page for processing this.......
    Code:
    try
     {
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      Connection conn=DriverManager.getConnection("jdbc:odbc:trail");
      try
      {
       String str1=request.getParameter("name");
       String str="insert into services values('',?,******);//How To INSERT DATE HERE
    
       PreparedStatement stmt=conn.prepareStatement(str);
    
       stmt.setString(1,str1);
       stmt.executeUpdate();
    
       out.print("Succesfully Inserted");
       conn.close();
      }
      catch(SQLException e)
      {
       out.print("SQL Not Executing");
      }
     } 
     catch(Exception e)
     {
      e.printStackTrace();
     }


    Now I want to Insert Date into my Table "services ".........my date format should be like this dd-mmm-yyyy What are necessary changes i have to make in InputMask or format field of date(Date/time) in Ms-Access and the code i have to use in Jsp Page to get date....
    And in my insert Statement firsld field is of Autonumber ,wat are problems with this during inserting....and after inserting one row i wat to retieve autonumber value ..


    Any help would be greatly appreciated ....many thanks in advance:happy:
     
  2. nimesh

    nimesh New Member

    Joined:
    Apr 13, 2009
    Messages:
    769
    Likes Received:
    20
    Trophy Points:
    0
    Occupation:
    Oracle Apps Admin
    Location:
    Mumbai
    Home Page:
    http://techiethakkar.blogspot.com
    First try inserting static data from the code, like

    String str="insert into services values('',?,#01-Jan-2009#)";

    If that works then you should get the data from HTML page in the format above, and then you can use the below statement

    String str="insert into services values('',?,#" & vardate & "#)";
    (where vardate is the variable used to store date from the HTML page)

    Remember # is the character that Access uses to identify that the value is a date value.
     
  3. sriram225

    sriram225 New Member

    Joined:
    May 22, 2009
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    Thanks for your Repli Nmesh i wil work on that!!!
     
  4. sriram225

    sriram225 New Member

    Joined:
    May 22, 2009
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    u didn't get my question bro!!!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice