Click here to Skip to main content
15,943,077 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am getting error during following code

Java
String str=jTable1.getModel().toString();
jTable2.setModel(str);


I want to store table model to access database in string format and retrieve this data from database in string format and assign it to table.

How I can convert this?
Posted
Comments
Sergey Alexandrovich Kryukov 23-Aug-14 23:11pm    
You are totally lost in the very beginning. You need to unlearn what you have learned so far and start from the very beginning. I am serious.
—SA
[no name] 24-Aug-14 16:11pm    
Actually I want to store model information in access database so i am using string if you have any other solution then please give it to me

1 solution

Why, why using the string at all? This is the biggest flaw and misconception of many present-day beginners: thinking that all objects are string. You need to work with objects themselves, not strings representing those objects. In your case, the string obtained from the model via toString() does not even represent the model.

—SA
 
Share this answer
 
Comments
[no name] 24-Aug-14 16:11pm    
Actually I want to store model information in access database so i am using string if you have any other solution then please give it to me
Sergey Alexandrovich Kryukov 24-Aug-14 20:38pm    
I already explained it for your. Your follow-up question is yet another confirmation that you have to start learning programming from the very beginning, otherwise nothing could help you.
—SA
[no name] 25-Aug-14 16:13pm    
Thank you sir for giving me your valuable time.
Actually I am beginners in java so i am trying some experiments of use of all methods of all important component like jTable,jList etc.
I check your profile and you are very genius in programming.
I know practice make perfect and in programming field we need lot of experiments to remember actual concept and i agree with you that i can not use String to setModel() method of jTable because it is volatile the rule of forcefully type casting of java

Thank you sir.
Sergey Alexandrovich Kryukov 25-Aug-14 16:32pm    
I guess, jTable2.setModel(jTable1.getModel()) would do, if this what you want.
If it makes sense for you, will you accept the answer formally (green "Accept" button)? In all cases, your follow-up questions will be welcome.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900