Results 1 to 4 of 4
- 06-11-2007, 04:20 AM #1
Senior Member
- Join Date
- Jun 2007
- Posts
- 164
- Rep Power
- 6
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());
- 06-11-2007, 01:44 PM #2
Senior Member
- Join Date
- Jun 2007
- Posts
- 119
- Rep Power
- 0
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
- 06-29-2007, 02:18 PM #3
Senior Member
- Join Date
- Jun 2007
- Posts
- 130
- Rep Power
- 0
Have you read the documentation?
What brings you rs.getDate?
What are your constructors for calendar?
- 06-30-2007, 02:47 PM #4
Senior Member
- Join Date
- Jun 2007
- Posts
- 164
- Rep Power
- 6
Similar Threads
-
Operator < cannot be applied to java.lang.Object, Object
By Albert in forum Advanced JavaReplies: 2Last Post: 11-26-2010, 02:12 AM -
Using PreparedStatement
By Java Tip in forum Java TipReplies: 0Last Post: 12-22-2007, 11:24 AM -
PreparedStatement
By Java Tip in forum Java TipReplies: 0Last Post: 12-05-2007, 03:56 PM -
Help me. PreparedStatement
By Felissa in forum JDBCReplies: 2Last Post: 06-28-2007, 05:03 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks