Cannot display SQL Query results in textboxes of application
843785Aug 20 2008 — edited Aug 20 2008Hello, I am trying to display the results of a SQL Query into 15 JTextBoxes using headers; I get the results back on click in the application only they show up in the text editor console and not the application. please let me know if you need to see more of the code.
public void run() {
PO conn = null;
try {
conn = this.Data;
for (int i = 0; i < 15; i++)
header.setText(conn.getHeaderField(headers[i]));
ARLinkConnection arl = new ARLinkConnection();
arl.rs.equals(header[15]);
//ARLinkConnection runnable = null;
//ARLinkConnection stmt = runnable;
quitLoading.setEnabled(false);
clearData.setEnabled(true);
runner = null;
}
catch (Exception e) {
status.setText("Error: " + e.getMessage());
}
}
This is my problem code; let me explain. PO is my application. header is in the code as JTextField[] header = new JTextField[15]; headers is String for JLabel[15]; now ARLinkConnection is my connection class to our oracle DB, it also contains the SQL Statement to run for results when the submitData button is pressed. This works by the way, only the results of the SQL Statement show up in the eclipse console, not my application. below is a look at that code for ARLinkConnection.java
rs = stmt.executeQuery("blah, blah, sql statement?)
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
int rowCount = 1;
while (rs.next()) {
System.out.println("Row " + rowCount + ": ");
for (int i = 1; i <= numberOfColumns; i++) {
System.out.print(" Column " + i + ": ");
System.out.println(rs.getString(i));
}
System.out.println("");
rowCount++;}
stmt.close();
}catch (SQLException ex){
System.err.println("SQL Exception :" + ex.getMessage());
}
}}
So, as you can see (I hope) I am calling ARLinkConnection, connecting, running the statement, and trying to display the results (rs) into header. The results in the console display column 1 through 15 accurately which is correct with the correct data.
Now, this is the part I?m not getting. Why is the results(rs) not displaying in the application for the 15 header textboxes? Am I setText wrong? Any thoughts or ideas, I would be more than willing to try, I trust your judgment. Please help or let me know if you need to see more of something?