how to set the datetime value using preparedstatement?

hi,

i want to set the string value which contains the date and time i wanted to set this string value in MSSql server database table one field datatype is datetime.

i am unable to perform this operation,

i am getting the error like

**** SQLException Error Code: 0

**** SQLException Error Message: [Microsoft][SQLServer 2000 Driver for JDBC]Valu

e can not be converted to requested type.

SimpleDateFormat sdfInput = new SimpleDateFormat( "yyyy/MM/dd" );

SimpleDateFormat sdfOutput =new SimpleDateFormat ( "MM/dd/yyyy" );

String textDate = contentDashBoard.getDateTimeStampReceived();

java.util.Date date = sdfInput.parse( textDate );

java.sql.Timestamp ts = new java.sql.Timestamp(date.getTime());

ps.setTimestamp(4,ts);

[802 byte] By [Annamalaii1a] at [2007-10-3 3:56:10]
# 1
> ps.setTimestamp(4,ts);Looks like the field isn't a datetime in that case.
kajbja at 2007-7-14 21:54:20 > top of Java-index,Java Essentials,New To Java...
# 2

>

> **** SQLException Error Code: 0

> **** SQLException Error Message:

> [Microsoft][SQLServer 2000 Driver for JDBC]Valu

> e can not be converted to requested type.

>

>

> SimpleDateFormat sdfInput = new SimpleDateFormat(

> mat( "yyyy/MM/dd" );

> SimpleDateFormat sdfOutput =new

> new SimpleDateFormat ( "MM/dd/yyyy" );

> String textDate =

> = contentDashBoard.getDateTimeStampReceived();

> java.util.Date date = sdfInput.parse( textDate );

> java.sql.Timestamp ts = new

> ew java.sql.Timestamp(date.getTime());

> ps.setTimestamp(4,ts);

Try printing textDate and check the format

pat2kina at 2007-7-14 21:54:20 > top of Java-index,Java Essentials,New To Java...