how to use a jtable

hello every body

i have a jtable in witch i want to insert the result of 2 sql requests on the same time one after the other.

but it never works for all the case i tried it shows me the first result or the second

this is my code :

publicvoid fil_table_Changed()

{

String project=null;

String task=null;

String soustask=null;

String[] columnNames ={"Project","Task","SubTask",};

String result;

String list2="select t.name_pro, t.name_tas,s.name_sta from task t, soustask s where t.name_tas=s.name_tas";

String list1="select t.name_pro,t.name_tas from task t where t.name_tas not in (select s.name_tas from soustask s)";

DefaultTableModel aModel = (DefaultTableModel) TA_list.getModel();

try

{

Class.forName("oracle.jdbc.driver.OracleDriver");

Connection maConnection = DriverManager.getConnection("jdbc:oracle:thin:@pc03.bss.local:1521:tms","system","tms");

Statement monEnonc镾QL = maConnection.createStatement();

ResultSet r閟ultatlist1 = monEnonc镾QL.executeQuery(list1);

ResultSet r閟ultatlist2 = monEnonc镾QL.executeQuery(list2);

aModel.setColumnIdentifiers(columnNames);

java.sql.ResultSetMetaData rsmd1 = r閟ultatlist1.getMetaData();

java.sql.ResultSetMetaData rsmd2 = r閟ultatlist2.getMetaData();

int colNo2 = rsmd2.getColumnCount();

int colNo1 = rsmd1.getColumnCount();

while(r閟ultatlist2.next())

{

Object[] objects =new Object[colNo2];

for(int i=0;i<colNo2;i++)

{

objects[i]=r閟ultatlist2.getObject(i+1);

}

aModel.addRow(objects);

}

while(r閟ultatlist1.next())

{

Object[] objects1 =new Object[colNo1];

for(int i=0;i<colNo1;i++)

{

objects1[i]=r閟ultatlist1.getObject(i+1);

}

aModel.addRow(objects1);

}

}

catch(SQLException ex1){System.out.println(ex1.toString());}

catch(ClassNotFoundException ex2){System.out.println(ex2.toString());}

catch(Exception ex3){System.out.println(ex3.toString());}

System.out.println("baaaaaaaaaaaaaaaa");

System.out.println(list1);

System.out.println("buuuuuuuuuuuuuuuuu");

System.out.println(list2);

}

can some one help me to display the 2 result at the same time i will be gretful

thanks for all>

[3829 byte] By [zmerlicnia] at [2007-10-2 8:42:03]
# 1
> int colNo2 = rsmd2.getColumnCount();> int colNo1 = rsmd1.getColumnCount();I simply believe colNo2 = colNo1 = 3. Above expr is redundant.And both result sets should have same object type sequence.Otherwise, it will fail.
hiwaa at 2007-7-16 22:44:12 > top of Java-index,Java Essentials,Java Programming...
# 2
And both result sets should have same object type sequence.the result is the same for the two queries (3 column "project, task,soustask)but i want to desplay the result in the same model one after the other
zmerlicnia at 2007-7-16 22:44:12 > top of Java-index,Java Essentials,Java Programming...
# 3

> And both result sets should have same object type

> sequence.

>

> the result is the same for the two queries (3 column

> "project, task,soustask)

Did you confirmed that using debugger?

> aModel.addRow(objects);

Try using Vector instead of array.

Or, try using setDataVector()

>

> but i want to desplay the result in the same model

> one after the other

hiwaa at 2007-7-16 22:44:12 > top of Java-index,Java Essentials,Java Programming...