views:

228

answers:

2

we are using hibernate in business layer,but the task is, by using the jtable in swings to display the dynamic data(swings) from the database. code:

Criteria criteria=session.createCriteria(User.class);

//here user.class is pojo class in hibernate.

List studentlist= criteria.list();

System.out.println("records"+studentlist);

here the data is showing in hibernate console, but how to represent that data in the format of "jtable".

+1  A: 

I recommend you read the tutorial How to use tables, from Java.

If you have a more specific need, edit your question to add details.

Gnoupi
+1, a link to a tutorial or a specific method is always appreciated. Not only does it provide information to this answer but it provides a resource for potential future problems.
camickr
+1  A: 

I've never used hibernate, but based on the code provided it looks like the data from your database is returned in a List. Therefore you will need to create a custom TableModel to access the data in the List.

The BeanTableModel might help you out.

camickr
+1 for adding more details and a possible solution (to a very unspecific question).
Gnoupi
wat u r thinking is same to my requirements.but i cannot understand.can u send me the acutal code about that requirements.like:Criteria criteria=session.createCriteria(User.class); List studentlist= criteria.list();//this studentlist can contains data(database).String[] columnNames = {"EMPLOYEE NO","FULL NAME","USER","PASSWORDS","DEPARTMENTS","PHONE"};//then how can i create rowdata?//can u send me any code or suggestions.its urgent!
harish0510
@harish - there is no "send me the code" solution to your problem, as we don't know your full requirements. Check the tutorial I gave in my answer, as it contains all information you will need to create and populate your JTable. It will require work from your side, it can't be answered in a few lines of code.
Gnoupi