-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: How to catch an out of range date error
PostPosted: Sun Mar 12, 2006 4:58 pm 
Newbie

Joined: Sat Jul 23, 2005 7:19 pm
Posts: 11
Hi, I'm trying to save dates on a table, and I want to know which is the best way to check that the date is not outside the range accepted by the database. In SQL Server (that accepts dates from 1753 to 9999) that type of error gives me error code 0.
Thanks.

Hibernate version:
3.1

Full stack trace of any exception that occurs:
16469 [AWT-EventQueue-0] ERROR util.JDBCExceptionReporter - Only dates between January 1, 1753 and December 31, 9999 are accepted.

Name and version of the database you are using:
SQL Server 2000 with jTDS


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 13, 2006 5:48 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Validate that sort of thing before it gets to the database. Probably immediately below the UI layer of your app.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 13, 2006 6:52 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
Perhaps this may help:

<column...
check=" dt > 1753 and dt < 9999"/>

(you may need to put the to_date(...) function (or sqlserver equivalent) around the years).

Or is it too late, in otherwords, the JDBC driver will pickup the "out of range" SQL error before it hits the db?

I would think it will make it to the database, and if the DT is out of range you'll get a CHECK violation.

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.