I use MS SQL Server and Java with JDBC to connect. I don't know how to display the result of my simple SQL queries in a Java Texfield. Displaying my data in a JTable is no problem with the external JAR rs2xml.
That works and prints my table in the panel.
String MaxQuery = "SELECT * FROM Employees";
PreparedStatement pst=con.prepareStatement(MaxQuery);
ResultSet rs=pst.executeQuery();
table.setModel(DbUtils.resultSetToTableModel(rs));
But when i want to display a simple query like "SELECT AVG(budget) FROM Employees" with 1 result, i want to print this in a textfield.
The method setModel doesn't work with Textfields. So i have tried something like that:
String AVGQuery = "SELECT AVG(budget) FROM Employees";
PreparedStatement pst=con.prepareStatement(AVGQuery);
ResultSet rs=pst.executeQuery();
textFieldAns.setText(rs.toString());
But that prints me "SQLServerResultSet:1". I want the result, and not the number of results. Hope u can help me by my little problem :).