Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / May 2004

Tip: Looking for answers? Try searching our database.

Java Datetime Strategies with SqlServer

Thread view: 
Ian Walsh - 12 May 2004 14:24 GMT
Hi,

I'm new to Java (from a .Net background) and I'm having problems
inserting a 'datetime' field into a SqlServer Database. I can insert a
date (01/01/2004) and a time (eg 01/01/1970 15:23) but not a Datetime
(eg 01/01/2004 15:23).

Can I do this using Java.Sql? If not, what is the usual strategy for
inserting datetime values into a SqlServer database.

All help appreciated.

Thanks.
Michael Rauscher - 12 May 2004 16:37 GMT
Ian Walsh schrieb:

> Hi,
>
[quoted text clipped - 7 lines]
>
> All help appreciated.

Try java.sql.Timestamp.

Bye
Michael
Sampsa Sohlman - 13 May 2004 08:20 GMT
> Hi,
>
[quoted text clipped - 7 lines]
>
> All help appreciated.

1. Use PreparedStatements ( see java.sql.PreparedStatement )
2. Use Timestamp to handle Date ( see java.sql.Timestamp )

This way you don't have to care date format, just handle the time.

- Sampsa

Signature

    -------------------------------------------
   // Sampsa Sohlman                        //
  //  My email can be found on my homepage //
 //   http://sampsa.sohlman.com           //
-------------------------------------------



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.