Solved

How can I insert time in a database and avoid a java.sql.SQLException error?

Posted on 2009-04-03
4
428 Views
Last Modified: 2012-06-22
I am using coldfusion to create a table that lists the "Calendar of Events".  I have a form that collects the STARTTIME and ENDTIME.  The data is entered into the form with the following format: hh:mm tt.  I now have the INSERT query accepting the data into the database by using:
 
<cfqueryparam value="#parsedatetime(Form.StartTime)#" cfsqltype="cf_sql_time">, <cfqueryparam value="#parsedatetime(Form.Endtime)#" cfsqltype="cf_sql_time">

I originally was trying to use cfsqltype="cf_sql_date" and a DATETIME setting in the database. I can get the insert into the database to work, but it puts the time in as 00:00:00.  When I switched the datatype in the database to TIME and used the code above, I was able to INSERT the data correctly, but now I am getting the following error when I try to query the data:

java.sql.SQLException: Value '00:00:00 can not be represented as java.sql.Time

My query is:
   <cfquery datasource="mainstreet_cafe" name="getAllEvents">
       SELECT * FROM calendar_of_events
   </cfquery>

Any ideas how I can get this to insert and query the data?
0
Comment
Question by:lonnyo
  • 2
4 Comments
 
LVL 19

Expert Comment

by:erikTsomik
ID: 24059586
what is the datatype for that field is in the database
0
 

Author Comment

by:lonnyo
ID: 24059612
When I get the error, the datatype is TIME (MySQL Database)
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 24062636
I do not usually use TIME fields,  I tend to use "datetime" with the cfsqltype="cf_sql_timestamp".  You might try that.

Also, if you run the query directly in MySQL what are the values of in those columns? Is it possible they might contain some invalid values?

0
 

Author Closing Comment

by:lonnyo
ID: 31566229
Thank you that worked.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article describes some very basic things about SQL Server filegroups.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now