| Author |
Can not be get and set values from the database
|
Hewa Naimanage Sumedha Amalka
Greenhorn
Joined: Oct 31, 2006
Posts: 19
|
|
Guys, I need to assign the value which got from database and show it as a text field of may frame created, But the thing is both of valuse are different (Strings and Textfield) So, can not be assigned Help me out, try { // Create a result set containing all data from my_table Statement stmt = conn1.createStatement(); ResultSet rs = stmt.executeQuery("SELECT IndexNo, RecidentTP, MobileTP FROM addbook"); // The inserting valu getting to a String String inpindx = inindx.getText(); // Get the data from the row using the column index String tblindx = rs.getString("IndexNo"); if (inpindx.equals(tblindx)) { NewFrame1 fr = new NewFrame1(); String srec1 = rs.getString("RecidentTP"); String smob1 = rs.getString("MobileTp"); //assigning to frame field to tables values // fr.sre1 = srec1.; // fr.smob = smob1; fr.setVisible(true); } else { JOptionPane.showMessageDialog(null,"Incorrect IndexNo"); } } catch (Exception e) { } inindx.setText(null);
|
SCJP 1.4 71%, SCWCD 1.5 84%, SCBCD 90%, SCMAD 98%
|
 |
Shailesh Chandra
Ranch Hand
Joined: Aug 13, 2004
Posts: 1076
|
|
Sumedha, You are invoking resultset without calling its next() method, I am not sure if its causing an exception or not....but certainly It will not return any result. Do something like this OR Shailesh
|
Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
|
 |
 |
|
|
subject: Can not be get and set values from the database
|
|
|