0

Hi Everyone, I am writing a program that i want to output some values from the database using a JoptionPane. I have the output using the System.Out.Println(), but i want a JOptionPane.
Would anyone please Help.....???
This is what i have so far;

st1 = con.createStatement();


rs2 = st1.executeQuery("select Block,Room,Bed from hostels where Block like 'Dip%'and Status='Available'");


                 //processing query results
                ResultSetMetaData metaData = rs2.getMetaData();
                int numberOfColumns = metaData.getColumnCount();
                System.out.println("Available Rooms\n");

              for (int i = 1; i <= numberOfColumns; i++) {
                    System.out.printf("%-8s\t", metaData.getColumnName(i));
                }
                System.out.println();


               while (rs2.next()) {
                    for (int i = 1; i <= numberOfColumns; i++) 
                   {   System.out.printf("%-8s\t", metaData.getColumnName(i));
                   //to use JOptionPane for output of the above

                   }
                    System.out.println();
                    }

Edited by mike_2000_17: Fixed formatting

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by javaAddict
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.