How To See Result From Mysql Query In Netbeans
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 a
Solution 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.
Post a Comment for "How To See Result From Mysql Query In Netbeans"