+ 4

Can anyone help me to retrive data from database

I have connect data base properly to java netbeans.I need to get row by row data to the jave and disply it it using system.out.println.can anyone help

13th Jan 2018, 2:59 AM
gayan dananjaya
gayan dananjaya - avatar
2 Réponses
+ 26
try { Class.forName .... ; Connection Con=Driver Manager ... ; Syring id,s; id=tf1.getText (); s="select * from <table name> where <field name>=id;" Statement st=Con.createStatement(); ResultSet rs=st.executeQuery (s); if (!rs.next ()) JOptionPane.showMessageDialog (null,"no such record"); else { tf2.setText (rs.getString ("<field name in table>"); . //fields to retrieve 👍 . . } } catch (Exception e){ JOptionPane.showMessageDialog(null,e.getMessage ());} //hope it helps☺
13th Jan 2018, 4:36 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 2
yeah thank you
31st Mar 2018, 6:11 PM
gayan dananjaya
gayan dananjaya - avatar