i wanted to create a gui java program that reads info from MySql then output it in a JTable.
but i first tried to use the JTable because it was my first time to use it.
It worked perfectly but when i tried to read from the database it doesn't display the JTable although i don't read anydata from the database here is the code.
the function IDs() when called the JTable don't appear.
please help i need to read data from this connect() method
Did you got any exception from the following code ?
private Statement connect() throws ClassNotFoundException, SQLException{ Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql://127.0.0.1/buba","root","root"); return con.createStatement(); }
Muralidharan.E
Junior Poster in Training
74 posts since Apr 2008
Reputation Points: 32
Solved Threads: 6
What exactly does your IDs() method do, e.g. why does it return an unused vector, and you don't even use the returned Vector in your constructor ?
Aviras
Junior Poster in Training
82 posts since Jul 2008
Reputation Points: 24
Solved Threads: 8
i coded it before to return data in that vector but when i saw that the JTable doesn't work with that vector i tried to just call it without using it. and i found that the JTable also don't work although it does nothing.
when i comment it.the JTable appears
That will be because your IDs() method gets only connection, create statement, but DOES NOT execute any query. Its like driving your car down to petrol station, park in front of pump and waiting to get it filled on its own.
peter_budo
Code tags enforcer
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
no actually i tried to read from the database and System.out.println the data and it output it perfectly i don't see any problem in the database
man please understand me i said i tried to let it do something before but it didn't work so i let it do nothing to see where is the problem and as you can see the problem is not in this method it's in the connection method
Make up your mind. Either it is working and you did not ruin query or it doesn't work and is throwing exception, in witch case you should post exception. You should use try/catch statement instead of hopping that Java will give you some meaningful messages on runtime
peter_budo
Code tags enforcer
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902