1

I want to create a static table using Java code to join it with another table from the database.

I know the number of columns and rows and the data, nothing of them is going to change at all, all of the values are constant.

The table will not be created in the database, it's only in the code and will be created when the application started.

I am new at Java coding, I used to work on C#, and I searched a lot through the internet, all what I found is how to create table in database which is not what I'm looking for. Any help would be appreciated.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
IBRA
  • 1,502
  • 3
  • 24
  • 56
  • How would you do it in C# – Aviram Segal Jan 03 '13 at 08:30
  • @AviramSegal using dataTable – IBRA Jan 03 '13 at 08:31
  • @HuiZheng i thought about it, but i want to know if there is another way may be more effective like dataTable in C#. but if isn't i'll use two-dimensional array, thanks – IBRA Jan 03 '13 at 08:38
  • 1
    @IbrahimSwaiss Maybe you can take a look at: http://stackoverflow.com/questions/1340283/datatable-equivalent-in-java and http://docs.oracle.com/javase/6/docs/api/javax/sql/rowset/WebRowSet.html – Hui Zheng Jan 03 '13 at 08:43
  • @HuiZheng the problem is the ResultSet not working offline, but as i read on the link u gave me, there is no equivalent to dataTable in java. i'm going to search some more thanks :) – IBRA Jan 03 '13 at 08:49
  • @Seem walak 7o6 el jawab bel answer mesh bel comments, fad7tna :) – IBRA Jan 15 '13 at 13:02

2 Answers2

1

You can use ResultSet but you'll see that it's not like DataTable in c# you can refer this link, maybe it will help you DataTable equivalent in Java

Community
  • 1
  • 1
Seem
  • 271
  • 1
  • 10
0

For a example of using a table in JSP see the answer here

In your case you could have a static List and add that to the "Cars" you get from the database.

Also if you want the table properly sorted take a look at implementing the Comparable interface.

Community
  • 1
  • 1
ozOli
  • 1,414
  • 1
  • 18
  • 26