Solved

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

Posted on 2009-04-03
4
433 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies 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…

839 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