f



java.sql.Date value truncated using JDBC in MS-SQL Server

Hi,
I'm trying to write a java.sql.Date to a database and the minutes/
seconds etc. are not being written. I've seen and tested many
examples
found via searches and still have come up with nothing. Here's what I
have:

java.sql.Date formation - recommended constructor forms:
java.sql.Date entryDttm = new
java.sql.Date(System.currentTimeMillis());
OR
java.sql.Date entryDttm = new java.sql.Date(new
java.util.Date().getTime());


// prepared statement insert
pstmt.setDate(1, entryDttm);
// what is written to database
2007-02-07 12:00:00.000


// what needs to be written
2007-02-08 09:37:25.793

The above date value is written when I insert using the SQL method
GETDATE() in a straight SQL Insert statement.

The field is stored in a MS SQL Server 8.0 database and is defined as
a 'datatime' or 'smalldatetime' field.

How can I replicate the results of GETDATE() into 'datetime' and
'smalldatetime' fields in
a MS-SQL Server database (or is it possible?). Would a timestamp
datatype make more sense?

I'm using MS_SQL Server JDBC drivers.

Any advice would be GREATLY appreciated!

0
ddog
2/8/2007 10:34:27 PM
comp.databases 3839 articles. 1 followers. Post Follow

1 Replies
883 Views

Similar Articles

[PageSpeed] 1

ddog wrote:
> Hi,
> I'm trying to write a java.sql.Date to a database and the minutes/
> seconds etc. are not being written. I've seen and tested many examples

You multi-posted this one to comp.lang.java.programmer as "Re: java.sql.Date 
truncated when written to DB. How to obtain full date?".

Follow-up set to cljp. Please cease multi-posting. Use cross-posting if you 
really want multiple groups.

- Lew
0
lew7583 (322)
2/9/2007 1:21:25 AM
Reply:

Similar Artilces:

Using MS SQL Server 2005 Enterprise Manager with MS SQL Server 2000
Hi Everyone, Most of our MS SQL Servers are still running on SQL 2000, but being I will soon be upgrading my workstation to Vista Business I'd like to install MS SQL 2005 Enterprise Manager to manage them all. When I tried to install MS SQL 2000 Enterprise Manager on Vista, it gave me a message saying it's not compatible, so I'll have to use 2005 I guess. We have LOTS of DTS scripts on our SQL 2000 server, and will 2005 EM work with these okay? Also I want to make sure SQL 2005 Enterprise Manager won't be adding to, changing, or 'upgrading' the DTS scripts or anythi...

MS SQL Server 2000 and MS JDBC SQL Server driver problems. (Connection timed out, followed by Error establishing socket)
I have downloaded the MS SQL Server 2000 Enterprise Evaluation edition, and the MS SQL 2000 Server JDBC driver. I have installed and configured the MS SQL Server 2000 onto two computers, which reside on the same network. (In fact, these two computers comprise the entire network). The network server (computer name=SUNCDS1), and the lone node (SUNCDS2), each have their own SQL Server 2000 instance. The SQL Server 2000 Enterprise Manager console on SUNCDS1 shows both SQL Server instances, the (local) instance, which is SUNCDS1, and also SUNCDS2. It may be worthwhile to mention t...

MicroSoft SQL Server 2000, Service Pack 2, AppDev SQL Server 2000 Accelerated Training [3 CDs], TransTrainer for Designing Microsoft SQL Server 2000 Databases v1.1, SQL Server 2000 Reporting Services,
MicroSoft SQL Server 2000, Service Pack 2, AppDev SQL Server 2000 Accelerated Training [3 CDs], TransTrainer for Designing Microsoft SQL Server 2000 Databases v1.1, SQL Server 2000 Reporting Services, (Enterprise), Developer Edition 64 Bit, other 16,000 more CDs, [ no dongles, no activations, etc ... needed ! ] (free donge)! No time limitation! CD NR 4203 MicroSoft SQL Server 2000 4in1 CD NR 9452 Microsoft SQL Server 2000 Service Pack 2 CD NR 11 298 AppDev SQL Server 2000 Accelerated Training [3 CDs] CD NR 12 000 Microsoft SQL Server 2000 Developer Edition 64 Bit ...

MicroSoft SQL Server 2000, Service Pack 2, AppDev SQL Server 2000 Accelerated Training [3 CDs], TransTrainer for Designing Microsoft SQL Server 2000 Databases v1.1, SQL Server 2000 Reporting Ser
MicroSoft SQL Server 2000, Service Pack 2, AppDev SQL Server 2000 Accelerated Training [3 CDs], TransTrainer for Designing Microsoft SQL Server 2000 Databases v1.1, SQL Server 2000 Reporting Services, (Enterprise), Developer Edition 64 Bit, other 16,000 more CDs, [ no dongles, no activations, etc ... needed ! ] (free donge)! No time limitation! CD NR 4203 MicroSoft SQL Server 2000 4in1 CD NR 9452 Microsoft SQL Server 2000 Service Pack 2 CD NR 11 298 AppDev SQL Server 2000 Accelerated Training [3 CDs] CD NR 12 000 Microsoft SQL Server 2000 Developer Edition 64 Bit CD NR 13...

MicroSoft SQL Server 2000, Service Pack 2, AppDev SQL Server 2000 Accelerated Training [3 CDs], TransTrainer for Designing Microsoft SQL Server 2000 Databases v1.1, SQL Server 2000 Reporting Services,
MicroSoft SQL Server 2000, Service Pack 2, AppDev SQL Server 2000 Accelerated Training [3 CDs], TransTrainer for Designing Microsoft SQL Server 2000 Databases v1.1, SQL Server 2000 Reporting Services, (Enterprise), Developer Edition 64 Bit, other 16,000 more CDs, [ no dongles, no activations, etc ... needed ! ] (free donge)! No time limitation! CD NR 4203 MicroSoft SQL Server 2000 4in1 CD NR 9452 Microsoft SQL Server 2000 Service Pack 2 CD NR 11 298 AppDev SQL Server 2000 Accelerated Training [3 CDs] CD NR 12 000 Microsoft SQL Server 2000 Developer Edition 64 Bit ...

MicroSoft SQL Server 2000, Service Pack 2, AppDev SQL Server 2000 Accelerated Training [3 CDs], TransTrainer for Designing Microsoft SQL Server 2000 Databases v1.1, SQL Server 2000 Reporting Services,
MicroSoft SQL Server 2000, Service Pack 2, AppDev SQL Server 2000 Accelerated Training [3 CDs], TransTrainer for Designing Microsoft SQL Server 2000 Databases v1.1, SQL Server 2000 Reporting Services, (Enterprise), Developer Edition 64 Bit, other 16,000 more CDs, [ no dongles, no activations, etc ... needed ! ] (free donge)! No time limitation! CD NR 4203 MicroSoft SQL Server 2000 4in1 CD NR 9452 Microsoft SQL Server 2000 Service Pack 2 CD NR 11 298 AppDev SQL Server 2000 Accelerated Training [3 CDs] CD NR 12 000 Microsoft SQL Server 2000 Developer Edition 64 Bit ...

SQL Server 2000 SQL Agent Error [393] Waiting for SQL Server to recover databases
While I was out of the office the Lan Team moved one of my SQL Server 2000 servers to a new network domain. Since then the maintenance job has not ran. The error log for the SQL Agents has the message listed in the subject line. I have not found any useful articles on the MS SQL Server site. Anyone know what might be wrong and how to fix it. HTH -- Mark D Powell -- Mark D Powell (Mark.Powell@eds.com) writes: > While I was out of the office the Lan Team moved one of my SQL Server > 2000 servers to a new network domain. Since then the maintenance job > has not ran. > &...

MS SQL using TSQL via JAVA jdbc
Hello. I am having trouble finding a descent API for executing TSQL via JDBC. I have tried the Microsoft driver AND the JDTS driver's but get the same syntax errors. I am hoping there is a good solution also for executing scripts using the same. Any help is MUCH appreciated.Thx. (asufty888@gmail.com) writes: > Hello. I am having trouble finding a descent API for executing TSQL > via JDBC. I have tried the Microsoft driver AND the JDTS driver's but > get the same syntax errors. I am hoping there is a good solution also > for executing scripts using the same. Any h...

how do you update a java.sql.date type in an ms access database
when i update a row in an access database the date field does not update to the correct date it brings up some funny date which i dont know where it comes from. Below is the method i use to update. maybe the date types are not compatable? thanks in advance, public static void bookIN(int custID, int rNumber,java.sql.Date bkInDate ){ try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String filename = "hotelDB.mdb"; String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="; database+=...

Read from a MS SQL Server database using OLE DB.
Hello I try to read from a MS SQL Server database using OLE DB. But when the table name is the same as the database name, I get the ERROR: File Q064.AAA97.DATA does not exist. Can anyone tell me how to read a table with the same name as the database. I use this libname. libname x oledb provider=sqloledb properties=("Integrated Security"=SSPI "Data Source"=A64 "Initial Catalog"=AAA97); This do not works. data AAA97; set x.AAA97; run; This works. data tab97; set x.tab97; run; Thanks Stefan ...

Problem Using 2 tables from Diferent DataBases (Ms-SQL Server)
Hy People i have this problem. I'm working with c55h and MS-SQL 7 and i have 2 databases Like These Database1 -> Tables: Customeres,Products Database2 -> Table: Inovoices When i do a Browse Over the Invoice Table, everything works Great the problem begins when i put fields from a table in other Database In this Case, The Customer's Name. (Database1) The browse behavior is extrange. it shows duplicated Records and extrange things. i resolved that problem using a VIEW of the customer table instead of the table. (the view is saved in the DataBase2) i gess if i would do that...

Using SQL Server IP for non-sql uses on a failover cluster
At my organization, users have started to use the virtual address created when SQL Server is installed on a failover cluster for non-SQL uses. I have always created an cluster IP resource in addition to the SQL cluster IP resource for non-SQL access to the server (like for mapping drives). What is the impact on SQL Server if people use the SQL virtual IP for non-SQL related access to the cluster? Is there a best practice that dictates that a separate IP should be provided for non-SQL access? Mark (google@markginsburg.com) writes: > At my organization, users have started to use the virtu...

Restore SQL Server 6.5 database in SQL Server 2000
Hi, Do you know if it is possible to restore database (backup) from SQL Server 6.5 in SQL Server 2000? Best Regards, Wojtek -- (Remove bez.syfu get my e-mail address) ...

Access database(Jet Engine) and SQL Server or SQL Server express
Hi, I am trying to find out what are the big differences between access database Jet engine and SQL Server? If I have serveral web applications (same content different copies) running as different sites(on IIS), each site using an access as a back-end database, all sites will be running simultaneously, all the access databases are on the same machine, on this approach, does each copy of access has its own Jet engine to handle database transaction or only has one Jet engine with multiple threads handles multiple copies of access database. Also, I'd like to know what kind database, and data...

Web resources about - java.sql.Date value truncated using JDBC in MS-SQL Server - comp.databases

Truncated trihexagonal tiling - Wikipedia, the free encyclopedia
In geometry , the truncated trihexagonal tiling is one of eight semiregular tilings of the Euclidean plane. There are one square , one hexagon ...

A warning for Google in the truncated novated lease
The car fringe benefit tax and novated lease business is a lurk whose days were always numbered, albeit a nice lurk enjoyed even by plenty of ...

Truncated Parramatta Road public consultation cost almost $2 million
It was the strategy on which the hopes and dreams of the inner west would be projected, and on which, seemingly, no expense was spared.

Mets Drop the Ball, but Fox Scores With Truncated World Series
... Matt Harvey inadvertently may have robbed Fox of a sixth World Series game, but the network still managed to put up big numbers with its truncated ...

Nicki Minaj Plays Truncated But Killer Hot 100 Festival Set
After a 30-minute delay, Nicki Minaj finally took the stage at the Billboard Hot 100 Festival to perform a truncated set.

Google's Truncated Titles
... limit on free Google Maps API: over 25,000 daily and you pay") As you can see from these examples, only a few words are removed, but the truncated ...


The Daily Hotness: Traveler's Truncated Trip
I've never really understood the internet's fascination with animal videos. Often enough, they're cute, but I've always been fairly disinterested. ...

Vista's Aero interface blamed for truncated battery life
Considering just how many copies of Windows Vista that Microsoft has moved, it's not too surprising that a few (potentially rightful) whiners ...

Obama ‘Redistribution’ Audio Clip Cited by GOP Was Truncated
Mandel Ngan/AFP/Getty Images The 14-year-old audio clip circulated by the Mitt Romney campaign this week to attack Barack Obama as favoring “redistribution” ...

Resources last updated: 2/10/2016 5:43:29 AM