Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    5

    Unanswered: resultset - string v's int?

    I've got this problem...when I try and read in my results from my resultset as Strings I have a problem when they are acutally integers...they don't get picked up.
    Is there any way of avoiding this problem? In some cases I'm reading in a String and some times I'm reading in an int. Is there any way of checking to see what type of object will be returned in the resultset?
    Thanks in advance!
    Lorna

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1

    Re: resultset - string v's int?

    Originally posted by shopaholic
    I've got this problem...when I try and read in my results from my resultset as Strings I have a problem when they are acutally integers...they don't get picked up.
    Is there any way of avoiding this problem? In some cases I'm reading in a String and some times I'm reading in an int. Is there any way of checking to see what type of object will be returned in the resultset?
    Thanks in advance!
    Lorna
    PHP Code:
    import java.sql.*;
    ...
    ResultSet rs stmt.executeQuery();
    ResultSetMetaData md rs.getMetaData();
    while (
    rs.next()) {
       if (
    md.getColumnType(1) == Type.INTEGER) {
          ...
       } else {
          ...
       }


  3. #3
    Join Date
    Mar 2004
    Posts
    5
    Thank you very much for that code.

    I've since learnt that my problem is my select <column> from <table> where <this>=<that> SQL statement. If <that> is a number then everything is fine but when it is a string no data gets returned.

    btw its Oracle 9i I'm linking to. and the sql statement generated will run fine in Oracle 9i-its just when i run it in my java class that it stops working.

    So once again if anyone has any ideas I'd been eternally grateful!
    Lorna

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •