databasemanager question

is there a way to tell if an sql lookup via databasemanager.getDataSetByQuery
worked?

i realize that if it works, it returns a JDataSet object;
what does it return if the lookup fails?

It will return null…

oh! i didn’t think of that!

thanks.

actually, i just tested that, and it’s not correct.

i have a query with a typo in it, and the result from
the databaseManager (as viewed in the debugger window)
is something like “java.sql.SQLException…”

does anyone know how to test for that?

testing if dataset has data:

if(dataset.getMaxRowIndex()>0 )
{
//go ahead
}
else
{
//error message
}

If you highlight the line in the debugger window you can copy paste it into a text editor

You can also use following code to capture the error into a variable.

application.setErrorCapture(true)
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, maxReturedRows);
var errorText = application.getLastErrorCode()

…or make it show up in the output window of the debugger:

application.output(errorText)

replace this code…

application.setErrorCapture(true) 
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, maxReturedRows); 
var errorText = application.getLastErrorCode()

with this…

var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, maxReturedRows); 
var errorText = dataset.getExceptionMsg()