Solved

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

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help with EXECUTE sp_executesql in ColdFusion cfquery 10 34
Exchange 2016 Databse move 5 56
Application.cfc - what is the order of events? 4 30
Mysql Left Join Case 10 55
This article describes some very basic things about SQL Server filegroups.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
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…

810 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