?
Solved

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

Posted on 2009-04-03
4
Medium Priority
?
437 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

762 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