1

When I run the netbeans debugger on my project I can't see the resulting tables from my SQL queries. How can I see those results in the same way as I see other variables?

Here is an example query:

<sql:query var="query" dataSource="myDB">
SELECT * FROM data
</sql:query>
<c:set var="queryInfo" value="${query.rows[0]}"/>

How can I see the queryInfo/query table using the debygger? When I try to show the result as a html table I don't get any error messages and I only get an empty table. As such I suspect the query return an empty table.

EDIT: To further clarify, my full query is:

SELECT * FROM weather_station
WHERE weather_station.belong_to = ? <sql:param value="${param.id}"/>
ORDER BY when_inspected DESC

There might be a problem with line 2 in the query, but I am not able to find the walue of param.id. It works in a different query on the same page.

EDIT2: Even though this particular problem is solved, I am still wondering how I easy can see the result from a query in netbeans. When I use JSP it does not show as a variable in the output window.

2
  • Generally any errors are output in the netbeans 'output' window, which will show the server log output. Not that there is a guarantee that there actually is an error, it might also just be the case that the query produces no results. When in doubt, first run the query outside of your application, say in MySQL workbench. Commented Nov 10, 2015 at 11:52
  • Edit the question if you have more relevant information, don't dump code in comments. Commented Nov 10, 2015 at 12:03

1 Answer 1

1
try{  
Class.forName("com.mysql.jdbc.Driver");  

Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/<database_name>","root","root");  

Statement stmt=conn.createStatement();  

ResultSet rs=stmt.executeQuery("<Your_Query>");  

while(rs.next())  
System.out.println(rs.get<DataType_of_first_column>(1)+"  "+rs.get<DataType_of_second_column>(2)+"  "+rs.get<DataType_of_third_column>(3));  

conn.close();
rs.close();
stmt.close();

}catch(Exception e){ System.out.println(e);}   

This is the entire code right from connecting to mysql and getting the result of your query. Hope it helps.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I'll give it a try after the holidays.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.