anyone have a link? I want to display data on the GUI that I made using NETBEANS..
I started learning java today,

I got error non-static variable jTextField1 cannot be referenced from a static context.

Connection con = DriverManager.getConnection("jdbc:mysql://localhost/sample", "", "");

      Statement stmt = (Statement) con.createStatement();
      String select = "SELECT name FROM sample WHERE name LIKE text";
      jTextField1.setText(select);

Error can be because JTextfield is defined outside static class "like main class". and u are accessing it in static class. In short you cant place non static variable in static functions.

What data base server you are using?

I actually dont sure about you problem. But I have done a similar code in Neatbean. In my code I have wight the SQL statement like below.

String SQL = "SELECT * FROM sample "; 
Statement stmt =  con.createStatement();
 stmt = con.createStatement();
            rs = stmt.executeQuery(SQL);
 jTextField1.setText(rs.getString(String.valueOf("column name from SQL table")));

Thank you.

If you can , give the full code.

String.valueOf("column name from SQL table")

why?

JamesCherrill

String.valueOf("column name of SQL table")

commented: Wasting Time -1

Yes, but why? String.valueOf(someString) is just someString. The method does nothing.

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.