This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes JDBC and Relational Databases 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 Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Can not be get and set values from the database" Watch "Can not be get and set values from the database" New topic

Can not be get and set values from the database

Hewa Naimanage Sumedha Amalka

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;


else {
JOptionPane.showMessageDialog(null,"Incorrect IndexNo");

catch (Exception e) {

SCJP 1.4 71%, SCWCD 1.5 84%, SCBCD 90%, SCMAD 98%
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081


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



Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
I agree. Here's the link:
subject: Can not be get and set values from the database