File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Syntax error converting datetime from character string. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Syntax error converting datetime from character string." Watch "Syntax error converting datetime from character string." New topic
Author

Syntax error converting datetime from character string.

S bitz
Ranch Hand

Joined: Jan 20, 2006
Posts: 80
Hi,
I am trying to insert some values in a database.I'm using prepared statements and this is my query


startDate and returnDate are of the format "YYYYMMDD"

This throws this error : Syntax error converting datetime from character string.

but when i change the query to

pstmt.setString(4,"20060905") this works fine.

I'm using SQL Server 2000.
Can anyone tell me how this can be fixed?

Thanks
Bitz
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

  • Convert Your String date to java.util.Date or Java.sql.Date
  • Set them as date in preparedStaement, NOT as String






  • Shailesh


    Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Syntax error converting datetime from character string.
     
    Similar Threads
    Convert DateTime Error
    ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
    howto modify database structure ?
    msyql jdbc problem.
    DataTime conversion