1. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    May 2003
    Brisbane, Australia
    Rep Power

    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.
  2. #2
  3. No Profile Picture
    Average Intelligence
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2003
    Rep Power
    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 12:38 AM.

IMN logo majestic logo threadwatch logo seochat tools logo