aspose file tools
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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply 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: 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
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Can not be get and set values from the database
 
Similar Threads
retrieved data from database and tick JTextBox in my form automatically
problem with using rs.getString() in servlet.
Split a string of data into array elements
Data type mismatch need to convert string to a number
Get data from TextField ?