Results 1 to 4 of 4
  1. #1
    Heather is offline Senior Member
    Join Date
    Jun 2007
    Posts
    164
    Rep Power
    7

    Default calendar object in preparedStatement

    I have an object and its attribute is calendar type, now I want to run a query in database, so I create a preparedStatement, in the data base there is a field who its type is date.

    But this error appears in the red line:


    cannot find symbol

    in interface preparedStatement
    method setDate(int, java.util.Calendar)

    Java Code:
     
    Calendar d = new GregorianCalendar();
     d.set(2007,6,6);
    String insertEvent = "INSERT INTO EVENTS(DATE,TYPE,COMMENT) VALUES(?,?,?);";
      ConnectionSingleton connection = ConnectionSingleton .getInstance();
      PreparedStatement preparedInsert = connection.getConnection().prepareStatement(insertEvent);
        [COLOR="Red"]    preparedInsert.setDate(1,ev.getDate().getTime());  [/COLOR]
            preparedInsert.setString(2,ev.getType());
      preparedInsert.setString(3,ev.getComment());

  2. #2
    Peter is offline Senior Member
    Join Date
    Jun 2007
    Posts
    119
    Rep Power
    0

    Default

    If you read API, the method getTime() of calendar class returns a java.util.Date
    According to API the method setDate() of the interface PreparedStatement receive a java. sql.Date

    I think that is the problem

  3. #3
    Jack is offline Senior Member
    Join Date
    Jun 2007
    Posts
    130
    Rep Power
    0

    Default

    Have you read the documentation?
    What brings you rs.getDate?
    What are your constructors for calendar?

  4. #4
    Heather is offline Senior Member
    Join Date
    Jun 2007
    Posts
    164
    Rep Power
    7

Similar Threads

  1. Replies: 2
    Last Post: 11-26-2010, 02:12 AM
  2. Using PreparedStatement
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-22-2007, 11:24 AM
  3. PreparedStatement
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-05-2007, 03:56 PM
  4. Help me. PreparedStatement
    By Felissa in forum JDBC
    Replies: 2
    Last Post: 06-28-2007, 05:03 PM

Posting Permissions

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