August 27th, 2003, 12:34 AM
Wierd problem reading database using java
Hi, I'm having trouble producing a web page in JSP that access an MS SQL Server 8.0 database. I execute the query
sql = "SELECT jobid, name, sum(hours) as hours, firstname, lastname";
sql = sql + " FROM machinehours";
sql = sql + " WHERE processid = " + processid ;
sql += " AND datetime BETWEEN " + safeParseDate(dateFrom) + " AND " + safeParseDate(dateTo);
sql += " GROUP BY jobid, name, firstname, lastname";
to get a result set. \
I'm going through the result set using while (rs.next())
however when i try and access rs.getFloat("hours") something goes horribly wrong. The class stops running and the browser just displays however much html it had received when the error occurred. I've tried running an integrity check on the database and it appears to be ok.
Any ideas as to what the problem could be?
I don't get any error messages or anything, the class just appears to stop and the html is often cut off halfway through a line.
August 27th, 2003, 01:22 AM
what's msSQL 8?
Your query seems to be fine.... i'd look into rs.getFloat("hours"). I'm not really a JSP master but I know that aggregate functions can return all number datatypes so if that getFloat is expecting a float type it should work. I'm not really sure what getFloat does but if there's a getInt or something like that i'd try that and see if it's a datatype/typecasting issue and also i'd try the jsp/java forum for this issue...
Last edited by unatratnag; August 27th, 2003 at 01:38 AM.