ODBC GUI on Netbeans

Having problem with private variables unedited

Page 1 of 1

2 Replies - 1288 Views - Last Post: 19 July 2009 - 02:16 AM Rate Topic: -----

#1 ladyinblack  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 9
  • View blog
  • Posts: 419
  • Joined: 08-April 09

ODBC GUI on Netbeans

Posted 18 July 2009 - 12:11 AM

Hi, I'm doing some GUI linking database from MS Access 2003, got that connection working, well Netbeans did not pick up any errors, so I assume it is working but my problem is that when I'm done with designing the GUI the variables that linked to each component is declared private at the bottom of the source code. When I want to used those variables the errors I'm coming up with are (1) if I'm using it in main, with main being static, it saying something like cannot use a non-static variable in a static context and (2) the fact that its private, I'm assuming that this can be used within this program. I'm not too clear on the private/public stuff, I get confused all the time. The other thing, I'm using this particular code

	   try
	   {
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
			Connection conn = DriverManager.getConnection("jdbc:odbc:; Driver={Microsoft Access Driver (*.mdb)}; dbq=BookStore.mdb");
			Statement command = conn.createStatement();
			ResultSet rs = command.executeQuery("Select * FROM Customers");
			while (rs.next())
			{
				[b]jTextField1.getText(rs.getString("Name"));[/b]
			}
			command.close();
			conn.close();
		}
		catch (Exception e)
		{
			System.out.println(e.toString());
		}



Note the code in bold, How do I code the data from the db to this program, because the above is not entirely correct?

Is This A Good Question/Topic? 0
  • +

Replies To: ODBC GUI on Netbeans

#2 Locke  Icon User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 516
  • View blog
  • Posts: 5,588
  • Joined: 20-March 08

Re: ODBC GUI on Netbeans

Posted 18 July 2009 - 12:20 AM

Call me crazy...but I don't think you mean getText()...I think you want setText()

:)
Was This Post Helpful? 1
  • +
  • -

#3 ladyinblack  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 9
  • View blog
  • Posts: 419
  • Joined: 08-April 09

Re: ODBC GUI on Netbeans

Posted 19 July 2009 - 02:16 AM

Here's the thing,

Locke thanks for solving that setText part for me.

But now in netbeans, as you see in the codes below, I cannot have the try...catch codes for the odbc in the main because of it being static and the variables are non-static. So, what do I do in this case. If I add this code in its own class, it gives me an error "illegal start of type". So I changed the class to a void function and no errors, but its not giving me the output I want, that is to read the information from the bookstore database. I'm just trying it with name first to see if it works, but no dice.

I GOT IT WORKING...

This post has been edited by ladyinblack: 19 July 2009 - 03:14 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1