SQL Server: Displaying result in Java Textfield : <p>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 <strong>rs2xml</strong>.</p>

<p>That works and prints my table in the panel.</p>

<pre><code>String MaxQuery = "SELECT * FROM Employees";
PreparedStatement pst=con.prepareStatement(MaxQuery);
ResultSet rs=pst.executeQuery();
table.setModel(DbUtils.resultSetToTableModel(rs));
</code></pre>

<p><strong>But</strong> when i want to display a simple query like "<em>SELECT AVG(budget) FROM Employees</em>" with 1 result, i want to print this <strong>in a textfield</strong>. </p>

<p>The method setModel doesn't work with Textfields. So i have tried something like that:</p>

<pre><code>String AVGQuery = "SELECT AVG(budget) FROM Employees";
PreparedStatement pst=con.prepareStatement(AVGQuery);
ResultSet rs=pst.executeQuery();
textFieldAns.setText(rs.toString());
</code></pre>

<p>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 :). </p>
