Results 1 to 3 of 3

Thread: date insertion in database problem

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2001
    Posts
    2

    date insertion in database problem

    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.io.*;
    import java.sql.*;
    import java.util.Date;
    import java.util.*;
    ---------
    ----------------
    -----------------------
    String kuntry=req.getparameter("country");
    String mem_id=req.getPatameter("cust_id");
    Date today=new Date();
    Date last_update;
    Date update;
    //check whether the client has downloaded the latest updates or not
    Statement st1=conn.createStatement();
    String query1="select OurUploadDate,CustomerDetails.LastUpdated from OurUpdateInfo,CustomerDetails where CustomerDetails.CustID='"+mem_id+"'";
    ResultSet rs1=st.executeQuery(query1);
    if(rs1.next())
    {
    last_update=rs1.getDate("LastUpdated");
    update=rs1.getDate("OurUploadDate");
    if(last_update==null) // IF LastUpdated FIELD IS BLANK
    {
    //codes to insert the update date and files downloaded
    pw.println("before insert..."); // WORKING TILL HERE . THIS DISPLAY IS APPEARING

    //NOT WORKING AFTER THIS
    // NO MODIFICATION IN DATABASE TAKING PLACE
    String inqry="update CustomerDetails set LastUpdated='"+today+"', Files_Downloaded='"+kuntry +"' where CustID='"+mem_id+"'";
    Statement inst=conn.createStatement();
    inst.executeUpdate(inqry);

    // THIS IS NOT DISPLAYED ON SCREEN
    pw.println("inserted into database");
    inst.close();


    KINDLY HELP .WHAT COULD BE THE REASON.IS THERE ANY INCOMPATIBILITY TAKING PLACE BETWEEN java.sql.Date and java.util.Date.
    IF YES HOW DO I HANDLE IT SO THAT TEH DATE AS WELL AS THE STRING kuntry IS INSERTED IN THE DATABASE.KINDLY NOTE THAT THE LastUpdated field is set as date type/short format.

  2. #2
    Lively Member
    Join Date
    Jan 2000
    Posts
    69

    possible problem

    Hey Manoj Kumar,

    The problem you have is similar to the one I had few months back when I was trying to pick up jsp and servlets. Unlike conventional java, with JSP you have to spell it more. It will give some problems, since sql and util package both define the date class. You have to directly import it from the package...
    does it help?

    I will come up an example shortly,


    Manoj

  3. #3
    VirtuallyVB
    Guest

    Lightbulb

    That was my first thought too, but I thought that the compiler should complain about the ambiguity. If this is your solution, then you need to be specific about the datatype
    java.util.Date
    java.sql.Date

    Post back if the compiler did not complain about the ambiguity in the first place. I'd like to know if it took the first or last "Date" instead of producing a compiler error.

Posting Permissions

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



Click Here to Expand Forum to Full Width