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){

oopS! sorry for double post! internet connection is slow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.