Results 1 to 1 of 1
  1. #1
    Join Date
    Mar 2004

    Exclamation Unanswered: JDBC ResultSet Problem


    Everything was working then it was not. I am looking for some suggestions:
    After the ResultSet was read in, I used to be able to update my text fields, but now, it does not see the column in the ResultSet. However, running a piece of test code, all things work. Any ideas?

    The table has 25 columns in it. And the ResultSet misses only certain ones...more towards the end. Not really a pattern. If I read only those fields in query, it is okay. My cludge fix is to read 1/2 the dbase and then the other 1/2.


    JTextField txtAccountName = new JTextField();

    ODBCconn MyConn1 = new ODBCconn();
    ResultSet Rec = MyConn1.QuerySQL("Select * from tblCustOwner Where CustRefId='" + strCustRefId +"'");

    if (
    // Test the Result set...
    ResultSetMetaData m = Rec.getMetaData();
    int columns = m.getColumnCount();
    for (int j=1; j<=columns; j++)
    System.out.print(m.getColumnName(j)+ "= ");
    System.out.print(Rec.getString(j).toString().trim( ) + " : ");
    System.out.print(Rec.findColumn(m.getColumnName(j) ) + "\n");
    // okay, the Test works fine.

    // this does not work...both areas are the same.
    // yes a jdbc.sql query shows all is fine...but not in javaville...
    txtState.setText(Rec.getString("State").toString() .trim());

    // and this does not work.
    String mySTring = Rec.getString(3).toString().trim();

    ... Okay, now I have it down to 2 fields reading from the database are causing a problem. which is of type char(2) the Rec.getString dies...
    Last edited by Tazlulu; 07-02-04 at 12:31.

Posting Permissions

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