Maneesh Godbole wrote:
mohd sherrez wrote:
Connection con;
like that?
Ummm...yes.
Please don't take this the wrong way, but if you need to ask how to declare variables, maybe you took a few steps back and started off with basics?
Check out http://docs.oracle.com/javase/tutorial/java/javaOO/variables.html
the con thing dosent work even with declaration
hi i am quite advanced into java i just have trouble trying to select a combobox item from that retrieve some values from a database and display it into my jtextfields
can i ask you for some help
how do i convert the following
public void popupMenuWillBecomeInvisible(PopupMenuEvent arg0) {
ResultSet rs = null;
String tmp=(String)cb_countries.getSelectedItem();
String sql="SELECT * FROM seacountries where country=?";
try{
PreparedStatement pst=con.prepareStatement(sql);
pst.setString(1, tmp);
rs=pst.executeQuery();
if(rs.next()){
String add1=rs.getString("IOC");
tb_ioc.setText(add1);
}
}
catch(Exception e){
}
//////INTO THIS FORMAT////
Step 1 -connect to database
db.getConnection();
step 2 - declare the SQL statement
String sql="SELECT * FROM seacountries where country=?";
rs = db.readRequest(dbQuery);
try{
while (rs.next())}
catch{
}
much thanks