Re: java sql exception error
| Newsgroups | gmane.comp.db.mysql.java |
|---|---|
| Message-ID | <OF61C0C321.BDC1A12E-ON802571E7.0032650B-802571E7.0032BB8C@Research.Quantel> |
[email protected] wrote on 10/09/2006 13:50:42: > Hi All, > > I am getting jave sql exception when I am trying to retrive start_time and > end-time values from MSQL database to calculate elapsed_time in minutes. > Here is the code, please help me see what I am doing wrong > > Time stime = res.getTime("starttime"); > Time etime = res.getTime("endtime"); > long elapsedTime = (etime.getTime()- stime.getTime()); > System.out.println("Elapsed time is: "+ elapsedTime); > stat.executeUpdate("UPDATE timing SET duration = elapsedTime"); > > I will appreciate any help that can help me manipulate this data. At the moment, you are trying to set the duration to the string to some kind of SQL variable or column called "elapsedTime". Remember that MySQL is running on another machine (potentially at least) and cannot "see" your Java variables. Try something like stat.executeUpdate("UPDATE timing SET duration =" + elapsedTime); which will cause Java to convert elapsedTime to a strign representation to be sent to MySQL. Alec -- MySQL Java Mailing List For list archives: http://lists.mysql.com/java To unsubscribe: http://lists.mysql.com/[email protected]