Board index » jbuilder » Odd behaviour when using QueryDataSet and JdbTable

Odd behaviour when using QueryDataSet and JdbTable


2004-10-22 11:49:05 PM
jbuilder11
The following is my code to create a QueryDataSet and add it to a
JDBTable. I am requesting a query that has more than 1 row and 1 column
however the JdbTable functions tell me there is only 1 row and 1 column.
I have included some print statments from my program in the "Output"
section. How do I get the right values from JdbTable?
Thanks,
Anthony
JPanel grid_panel = new JPanel(new BorderLayout());
String sql = "select name, exp_id, type, remark, expression from
_system.cal_defn order by name, type";
dsview = new com.borland.dx.dataset.DataSetView();
com.borland.dx.sql.dataset.QueryDescriptor querydescriptor = new
com.borland.dx.sql.dataset.QueryDescriptor(dwa.DWA_Application.database,
sql, dsview, false, Load.ALL);
query = new com.borland.dx.sql.dataset.QueryDataSet ();
query.setAccumulateResults(false);
query.setQuery(querydescriptor);
table = new com.borland.dbswing.JdbTable ();
table.setDataSet(query);
query.executeQuery();
JScrollPane scrollpane = new JScrollPane(table);
grid_panel.add(scrollpane, BorderLayout.CENTER);
this.getContentPane().add(grid_panel, BorderLayout.CENTER);
System.out.println("Query rows = " + query.getRowCount() + " cols= " +
query.getColumnCount());
System.out.println("Table rows = " + table.getRowCount() + " cols= " +
table.getColumnCount());
System.out.println("TableModel rows = " + table.getModel().getRowCount()
+ " cols= " + table.getModel().getColumnCount());
System.out.println("TableColumnModel cols = " +
table.getColumnModel().getColumnCount());
System.out.println("Table Header col count" +
table.getTableHeader().getColumnModel().getColumnCount());
Output
Query rows = 1012 cols= 5 // this is what I expect, why aren't the
others matching this
Table rows = 1 cols= 1
TableModel rows = 1 cols= 1
TableColumnModel cols = 1
Table Header col count1
 
 

Re:Odd behaviour when using QueryDataSet and JdbTable

Thanks for the quick reply.
I am trying to NOT use the designer as I am building sql on the fly. I
should say that the data does appear perfectly in the application. Its
just that the functions don't seem to work. Is there a certain order
that I need to following in my code?
Please help, thanks.
Paul Nichols (TeamB) wrote:
Quote
"sdf" < XXXX@XXXXX.COM >wrote in message
news:41792b56$ XXXX@XXXXX.COM ...

>The following is my code to create a QueryDataSet and add it to a
>JDBTable. I am requesting a query that has more than 1 row and 1 column
>however the JdbTable functions tell me there is only 1 row and 1 column.
>I have included some print statments from my program in the "Output"
>section. How do I get the right values from JdbTable?
>
>
>Thanks,
>
>Anthony
>

Right click on the QueryDataSet from the designer. This should reveal a
QueryDataSet designer that will list all fields. Make sure that they are all
visible. Set the properties as you want them to appear.


 

Re:Odd behaviour when using QueryDataSet and JdbTable

I think I figured out the problem. Although I am not happy with the
situation. It turns out that I tryng to get the number of column prior
to the window being added to a Desktop pane and being made visible. I
have discovered that you should only query the JdbTable tablecolumns
model AFTER the frame is made visible.
Anthony
sdf wrote:
Quote
Thanks for the quick reply.

I am trying to NOT use the designer as I am building sql on the fly. I
should say that the data does appear perfectly in the application. Its
just that the functions don't seem to work. Is there a certain order
that I need to following in my code?

Please help, thanks.


Paul Nichols (TeamB) wrote:

>"sdf" < XXXX@XXXXX.COM >wrote in message
>news:41792b56$ XXXX@XXXXX.COM ...
>
>>The following is my code to create a QueryDataSet and add it to a
>>JDBTable. I am requesting a query that has more than 1 row and 1 column
>>however the JdbTable functions tell me there is only 1 row and 1 column.
>>I have included some print statments from my program in the "Output"
>>section. How do I get the right values from JdbTable?
>>
>>
>>Thanks,
>>
>>Anthony
>>
>
>Right click on the QueryDataSet from the designer. This should reveal a
>QueryDataSet designer that will list all fields. Make sure that they
>are all
>visible. Set the properties as you want them to appear.
>
>

 

{smallsort}

Re:Odd behaviour when using QueryDataSet and JdbTable

"sdf" < XXXX@XXXXX.COM >wrote in message
Quote
The following is my code to create a QueryDataSet and add it to a
JDBTable. I am requesting a query that has more than 1 row and 1 column
however the JdbTable functions tell me there is only 1 row and 1 column.
I have included some print statments from my program in the "Output"
section. How do I get the right values from JdbTable?


Thanks,

Anthony

Right click on the QueryDataSet from the designer. This should reveal a
QueryDataSet designer that will list all fields. Make sure that they are all
visible. Set the properties as you want them to appear.
 

Re:Odd behaviour when using QueryDataSet and JdbTable

sdf wrote:
Quote
I think I figured out the problem. Although I am not happy with the
situation. It turns out that I tryng to get the number of column prior
to the window being added to a Desktop pane and being made visible. I
have discovered that you should only query the JdbTable tablecolumns
model AFTER the frame is made visible.
Maybe it's related to the fact that UI components aren't
"realized" until shown? Try moving the System.out.println
code to an override of "addNotify()". In that overriding
method, be sure to call super.addNotify() first.
--
Paul Furbacher (TeamB)
Save time, search the archives:
www.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
www.visi.com/~gyles19/fom-serve/cache/1.html
Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.