You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Christopher Cheng <ma...@chrisshare.net> on 2003/04/25 12:30:45 UTC

Problem setting Date and Time for MSSQL: a driver's bug?

Since PlatformMsSQLServerImpl does not override PlatformDefaultImpl's setObjectForStatement, 

if sqlttype = 92 (Time) is used, the function executes
ps.setObject(index, value, sqlType) where value is an object of Time and the sqlType is 92

If I am using Microsoft's JDBC Driver SP1, only the date part but not the time part is updated. The get around is to override the function with the following

if (sqlType = 92) ps.setTime(index, (Time) value))
else ps.setObject(index, value, sqlType)

However, this does not solve the problem, the value would be "1/1/1970 x:xx:xx". You can see that the date part is not updated

On the other hand, if I use JSQLConnect's JDBC Driver and overrides setObjectForStatement with the codes above, it works fine. But this driver is not without problem, if I use java.sql.Date instead of java.sql.Time, even I set the time for java.sql.Date, the time is not updated.

Seems that the problem is driver specific, does anybody has a clear solution?




Re: Problem setting Date and Time for MSSQL: a driver's bug?

Posted by Vic Cekvenich <vc...@basebeans.com>.
Cheng,

Cross posting is a bad practice!

This does not have to do much with Struts. Why not ask on the MS JDBC group?

Coding at JDBC level is not a good idea.


.V


Most people use a DAO layer, such as iBatis DB Layer (SQL) or Hibreante 
(O/R).
You would use a DAO layer for the same reason you would not want to 
write a framework, but start with a framework.



Christopher Cheng wrote:

>Since PlatformMsSQLServerImpl does not override PlatformDefaultImpl's setObjectForStatement, 
>
>if sqlttype = 92 (Time) is used, the function executes
>ps.setObject(index, value, sqlType) where value is an object of Time and the sqlType is 92
>
>If I am using Microsoft's JDBC Driver SP1, only the date part but not the time part is updated. The get around is to override the function with the following
>
>if (sqlType = 92) ps.setTime(index, (Time) value))
>else ps.setObject(index, value, sqlType)
>
>However, this does not solve the problem, the value would be "1/1/1970 x:xx:xx". You can see that the date part is not updated
>
>On the other hand, if I use JSQLConnect's JDBC Driver and overrides setObjectForStatement with the codes above, it works fine. But this driver is not without problem, if I use java.sql.Date instead of java.sql.Time, even I set the time for java.sql.Date, the time is not updated.
>
>Seems that the problem is driver specific, does anybody has a clear solution?
>
>
>
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Problem setting Date and Time for MSSQL: a driver's bug?

Posted by Vic Cekvenich <vc...@basebeans.com>.
Cheng,

Cross posting is a bad practice!

This does not have to do much with Struts. Why not ask on the MS JDBC group?

Coding at JDBC level is not a good idea.


.V


Most people use a DAO layer, such as iBatis DB Layer (SQL) or Hibreante 
(O/R).
You would use a DAO layer for the same reason you would not want to 
write a framework, but start with a framework.



Christopher Cheng wrote:

>Since PlatformMsSQLServerImpl does not override PlatformDefaultImpl's setObjectForStatement, 
>
>if sqlttype = 92 (Time) is used, the function executes
>ps.setObject(index, value, sqlType) where value is an object of Time and the sqlType is 92
>
>If I am using Microsoft's JDBC Driver SP1, only the date part but not the time part is updated. The get around is to override the function with the following
>
>if (sqlType = 92) ps.setTime(index, (Time) value))
>else ps.setObject(index, value, sqlType)
>
>However, this does not solve the problem, the value would be "1/1/1970 x:xx:xx". You can see that the date part is not updated
>
>On the other hand, if I use JSQLConnect's JDBC Driver and overrides setObjectForStatement with the codes above, it works fine. But this driver is not without problem, if I use java.sql.Date instead of java.sql.Time, even I set the time for java.sql.Date, the time is not updated.
>
>Seems that the problem is driver specific, does anybody has a clear solution?
>
>
>
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org