{"id":183,"date":"2013-07-22T09:07:14","date_gmt":"2013-07-22T09:07:14","guid":{"rendered":"http:\/\/codethataint.com\/blog\/?p=183"},"modified":"2013-07-22T09:08:30","modified_gmt":"2013-07-22T09:08:30","slug":"java-sql-sqlexception-illegal-hour-value","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/java-sql-sqlexception-illegal-hour-value\/","title":{"rendered":"java.sql.SQLException: Illegal hour value"},"content":{"rendered":"<p>MySQL TIMEDIFF function runs well in MySQL but with JDBC it generate SQL Exception.<br \/>\nThe problem is that the TIMEDIFF(expr1,expr2) function returns expr1 \u2013 expr2 expressed as a time value. <\/p>\n<p>This value is handled by java.sql.Time. But TIMEDIFF( , ) may return (for example) 12:45:00 or 40:30:01 as the case may be. For first value it works but for the second value it is not a proper time value according to java.sql.Time, hence the exception.<\/p>\n<p>To get rid of this problem is to use concat as follows<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nCONCAT('',TIMEDIFF(expr1,expr2))\r\n<\/pre>\n<p>Now the returned value will be a String instead of a Time and which prevents JDBC from parsing it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL TIMEDIFF function runs well in MySQL but with JDBC it generate SQL Exception. The problem is that the TIMEDIFF(expr1,expr2) function returns expr1 \u2013 expr2 expressed as a time value. This value is handled by java.sql.Time. But TIMEDIFF( , ) may return (for example) 12:45:00 or 40:30:01 as the case may be. For first value&hellip; <a href=\"https:\/\/codethataint.com\/blog\/java-sql-sqlexception-illegal-hour-value\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[],"class_list":["post-183","post","type-post","status-publish","format-standard","hentry","category-exceptions"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=183"}],"version-history":[{"count":3,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/183\/revisions"}],"predecessor-version":[{"id":186,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/183\/revisions\/186"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}