Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

[HELP] on sync of JTable with DB  RSS feed

 
Aron Jhed Amiscosa
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, guys, i have a problem on refreshing the items on my JTable...

i am using a custom AbstractTableModel....

the JTable is contained within a JInternalFrame....
it is being called by another method on another class which contains the JDesktopPane...

i searched some solutions here on JavaRanch and other Java Prog. sites... but i am yet to avail a working solution to my problem...


and it refreshes the table at background but the JTable still has the same components after i added a new row.
but if i open another instance of it, the JTable contains the newly added rows...
please help me guys.. i'm so confused now..

this is the output shown after using it...

got meta = com.mysql.jdbc.JDBC4DatabaseMetaData@d75c47
got column results
name: ID
type: 5
name: Surname
type: 12
name: First_Name
type: 12
name: Middle_Name
type: 12
name: Year
type: 12
name: Course
type: 12
name: Section
type: 12
name: Age
type: 5
name: Gender
type: 12
name: Address
type: -1
name: Email
type: -1
Created model with 1 rows

got meta = com.mysql.jdbc.JDBC4DatabaseMetaData@1e779a1
got column results
name: ID
type: 5
name: Surname
type: 12
name: First_Name
type: 12
name: Middle_Name
type: 12
name: Year
type: 12
name: Course
type: 12
name: Section
type: 12
name: Age
type: 5
name: Gender
type: 12
name: Address
type: -1
name: Email
type: -1
Created model with 2 rows


the database is being in sync but the table is not.. please help...
 
Mikko Kohtamäki
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using AbstractTableModel are you firing TableModelEvent like DefaultTableModel does when inserting new rows...
 
Paul Clapham
Sheriff
Posts: 22503
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mikko Kohtamäki wrote:Using AbstractTableModel are you firing TableModelEvent like DefaultTableModel does when inserting new rows...


Yes, that's right, you have to do that. Calling the model's methods whose names start with "fire" is the most convenient way to do it.
 
Aron Jhed Amiscosa
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the tips..

as far as i understand it, i redo the code on my custom model...



then i have to call it on the other class...

please tell me if i'm doing it right...



EDIT: WOW! Thank you guys for your help... its working now...

i just missed the part of setting the model again to the table...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!