GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes issue in Jtable when populates value from oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "issue in Jtable when populates value from oracle " Watch "issue in Jtable when populates value from oracle " New topic
Author

issue in Jtable when populates value from oracle

Azeem Rathore
Ranch Hand

Joined: Jun 26, 2013
Posts: 30
[color=darkred]Hi i am new to java programming and using oracle in back end and i have table hr_departments which contain 14 column
i have made function in java which retrieves three column dep_code,dep_name, dep_short_name in department class
and in form class in the form i have jtable which dynamically fill the jtable from database i have made update_table function and call in constructor so that when ever the form load it filled the jtable populates automatically from the database values
now issue is this i had 11 records in the database table it loads in the jtable correctly . i empty table values from database and load again it shows my same 11 records in my jtable . i create another database with different name and insert 3 records it populates three records then later i empty that database too it still showing three records and all the values in the jtable i check on database count row it shows zero even i set joption pane to display number to rows it display correct answer but jtable is not updating once it is populated.please tell me what is the issue . Alaso the images i upload

here is my function


update function which calls this method is below
[/color]



[Thumbnail for gui.jpg]

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8



I don't see where you are declaring that variable "data". It's some type of collection, clearly, and I don't see any code which clears it before you start loading data into it from your ResultSet.
Azeem Rathore
Ranch Hand

Joined: Jun 26, 2013
Posts: 30
Paul Thanks for the reply here is my department_form code i am declaring data variable in form class

i already post the getall employees function above kindly help please i am still looking for the solution
thanks in advance
Ganesh Malaichamy
Greenhorn

Joined: Feb 11, 2011
Posts: 27
When you are saying that you are loading again , Are you referring to close the window and opening again?.I am not seeing the connection close statement.Also did you got the chance to see that the Update_Table is getting executed when you are loading the program again.
Azeem Rathore
Ranch Hand

Joined: Jun 26, 2013
Posts: 30
yes loading again is i close the program and then run it again .
hmm i do not understand how to check Update_Table is getting executed or not i am only in 2nd semester of my Bachelors and new to programming can you please help me how to fix it ?
how and where to close the statement? i didnt close any connection .
Thanks ganesh
Ganesh Malaichamy
Greenhorn

Joined: Feb 11, 2011
Posts: 27
You need to add System.exit(0); after the line 89 in your code. Refer this link for the details http://www.coderanch.com/t/346186/GUI/java/InvokeLater. Adding System.exit might solve the problem but that is not the clean solution. You need to add frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) for the frames you are adding. From the code it seems like the resources are not released properly.For the simpler debugging you can add System.out.println statement inside the methods.This will get displayed during the program execution in the console. You can set the break point and debug the program.
Azeem Rathore
Ranch Hand

Joined: Jun 26, 2013
Posts: 30
I added System.exit(0); after line 89 when i run the program frame open and suddenly close like just glimpse of the frame
Ganesh Malaichamy
Greenhorn

Joined: Feb 11, 2011
Posts: 27
Just in main call the frame with out thread like
and see that solves the problem.
Azeem Rathore
Ranch Hand

Joined: Jun 26, 2013
Posts: 30
i went to the netbeans databases and there i connect database and went to hrm netbeans showing 11 records in my table but oracle showing no record now i understand it is getting data from the netbean database
can you tell me why?
i hope you understand my english my first language is german so bear with me
Azeem Rathore
Ranch Hand

Joined: Jun 26, 2013
Posts: 30
i mean to say when i view record from toad for oracle and connect database and view the tables it does not show any record but in the netbeans >services> databases> and connect oracle it shows my schema called hrm when i click on that hrm it shows my tables and in my table there is data 11 records
am i connected to correct database? kindly tell me please
Ganesh Malaichamy
Greenhorn

Joined: Feb 11, 2011
Posts: 27
Check the connection settings (ServerName,schemaName) from both the TOAD and the NetBeans. Try to insert the same data from both the end and see both are reflecting the changes.
 
GeeCON Prague 2014
 
subject: issue in Jtable when populates value from oracle