wood burning stoves*
The moose likes JDBC and the fly likes Can not be get and set values from the database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Can not be get and set values from the database" Watch "Can not be get and set values from the database" New topic
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: 1081

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
 
Don't get me started about those stupid light bulbs.
 
subject: Can not be get and set values from the database
 
Similar Threads
problem with using rs.getString() in servlet.
Data type mismatch need to convert string to a number
Get data from TextField ?
retrieved data from database and tick JTextBox in my form automatically
Split a string of data into array elements