DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2005

    Incompatible type for declaration. Can't convert int to java.sql.ResultSet.

    I'm running an sql statement and using the ResultSet class in java, but I am having the following error message:

    Incompatible type for declaration. Can't convert int to java.sql.ResultSet.
    ResultSet rs=stmt.executeUpdate(sql);

    I understand that executeUpdate does not return a resultset, it does return an int, but how can I modify my code to get it to work?

    My code is as follows:
    String sql = "SELECT patient.patientName, patientClaim.claimNo, claim.claimNo, claim.submittedDate,"+
    "claim.totalCost, claim.SOB_ID, claim.visitID, claimStatus.statusID, status.StatusName,"+
    "employee.employeeID, SOB.claimType FROM SOB INNER JOIN (status INNER JOIN "+
    "((employee INNER JOIN ((claim INNER JOIN (patient INNER JOIN patientClaim ON"+
    "patient.patientID = patientClaim.patientID) ON claim.claimNo = patientClaim.claimNo)"+
    "INNER JOIN employeeClaim ON claim.claimNo = employeeClaim.claimNo) ON employee.employeeID"+
    "= employeeClaim.employeeID) INNER JOIN claimStatus ON (patientClaim.claimNo = claimStatus.claimNo) AND (claim.claimNo" +
    "= claimStatus.claimNo)) ON status.statusID = claimStatus.statusID) ON SOB.SOB_ID = claim.SOB_ID"+
    "WHERE (((status.StatusName)='Pending') AND ((employee.employeeID)="request.getParameter("userID"));";

    Statement stmt =con.createStatement();
    ResultSet rs=stmt.executeUpdate(sql);

  2. #2
    Join Date
    Oct 2005
    Very easy Maria, as executeUpdate dosent returns a ResultSet but an int you should something like this:

    int returnCode = stmt.executeUpdate(sql);

    Answer provided by http://www.consultoriajava.com

  3. #3
    Join Date
    Sep 2005
    The reason why I am not using an integer is because I cannot invoke a method on an int.

    lower down in the code, I need to loop through the ResultSet and display the results such as while
    rs.next(). If I declare rs of type int, I cannot loop through.

  4. #4
    Join Date
    Oct 2005
    If you want to launch a query you should use the method executeQuery() instead of executeUpdate()

    Answer provided by http://www.consultoriajava.com

  5. #5
    Join Date
    Sep 2005
    It's amazing, I used executeQuery( ) before and I still had the same error message. Now I am using it again and it seems to be working!

    However, I am getting another error message when I loop through the ResultSet. The code goes as follows:
    while (rs.next())

    out.println("<tr> <td>"+rs.getInt("claimNo") +"</td>");

    out.println("<td>"+rs.getDate("submittedDate") +"</td>");

    out.println("<td>"+rs.getInt("totalCost") +"</td>");

    out.println("<td>"+rs.getDate("dateOfSymptoms") +"</td>");

    out.println("<td>"+rs.getString("statusName") +"</td>");

    out.print("<td>"+rs.getString("patientName")+ "</td></tr>");


    The error message is:

    "[ODBC Driver Manager] Invalid cursor state"

  6. #6
    Join Date
    Oct 2005
    Your code seems to be ok (not great but should work).

    It would be of help to see your previous code, the error you are receiving is usual when you try to do


    when you havent done yet


    Answer provided by experts at http://www.consultoriajava.com

Similar Threads

  1. how to convert wchar_t* type to int
    By swapnil_paranja in forum C++
    Replies: 3
    Last Post: 06-30-2005, 06:55 AM
  2. Replies: 1
    Last Post: 06-10-2002, 11:10 AM
  3. Producer Consumer Thread
    By Chirag in forum Java
    Replies: 6
    Last Post: 04-10-2002, 05:22 AM
  4. INSERT for multiple tables with IDENTITY
    By Kay in forum Database
    Replies: 1
    Last Post: 07-04-2001, 05:18 AM
  5. What is the UDT?
    By Tahui in forum VB Classic
    Replies: 2
    Last Post: 11-22-2000, 10:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center