0

why this code is not working?,

error: non-static variable jTextField1 cannot be referenced from a static context

try{
            Connection con = DriverManager.getConnection("jdbc:mysql://localhost/sample", "", "");
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT name FROM testtable");
            
            while (rs.next()){
                String n = rs.getString("name");               
                jTextField1.setText(n);
                 }            
            stmt.close();
            con.close();                  
            
        }catch(Exception e){
1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by aldeene
0

oopS! sorry for double post! internet connection is slow

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.