Getting a reference to a query column and DataSetView information


2004-10-25 09:53:17 PM
jbuilder14
The following code is my entire JBInit() function. Please tell me what
the problem is. The issue relates to the section in {}. When I call the
section BEFORE the query.executeQuery() I get a NullPointer error when I
execute "exp_id_column.setAutoIncrement(true);". I believe this is
because there isn't a real resultset available which makes sense.
However, when I execute the {} section after the query.executeQuery()
function, I recieve an error that the dataset must be closed. My
question is, where can I execute my {} section? Also, is there a place I
can get good examples of this stuff including how to use the DataSetView()?
Anthony
this.getContentPane().setLayout(borderLayout1);
//Data Grid
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);
query.executeQuery();
{
com.borland.dx.dataset.Column exp_id_column = query.getColumn(1);
exp_id_column.setAutoIncrement(true);
exp_id_column.setRowId(true);
query.setTableName("_system.cal_defn");
// query.setResolver(resolver);
}
table = new com.borland.dbswing.JdbTable ();
table.setDataSet(query);
JScrollPane scrollpane = new JScrollPane(table);
grid_panel.add(scrollpane, BorderLayout.CENTER);
this.getContentPane().add(grid_panel, BorderLayout.CENTER);