Code: Select all
function getChangeData(partnum) {
var subSql="Exec ChangeTracker @Partnum='" + partnum + "'";
var subRs,subStmt;
var subCon=system.getDatabaseConnection("VAULT");
try {
subStmt=subCon.prepareStatement(subSql);
subRs=subStmt.executeQuery();
while (subRs.next()) {
// Logic goes here
}
} catch (e) {
// Dump the SQL for debugging purposes
print("An error occurred reading the database with the query " + subSql);
print(e);
if(subRs) subRs.close();
if(subStmt) subStmt.close();
if(subCon) subCon.close();
return null;
} finally {
if(subRs) subRs.close();
if(subStmt) subStmt.close();
if(subCon) subCon.close();
}
// data is returned here
}
Code: Select all
An error occurred reading the database with the query Exec ChangeTracker JavaException: java.sql.SQLException: StandardXAConnectionHandle:prepareStatement should not be used outside an EJBServer
java.lang.NullPointerException
EDIT: I edited the db connection settings for the database connection VAULT so that now it shows:
min:5
max:300 (probably overkill)
checkLevel:2
validationQuery:select 1
preparedStatementCache:0
I forgot to mention that the function above called getChangeData() is called by another function which loops through a large set of data and calls getChangeData() many times, each time providing a different part number. After adjusting the DB connection values, the code executes for a while (Over an hour and a half) and now gives me this error
JavaException: com.ebasetech.xi.exceptions.FormRuntimeException: Error getting connection using Database Connection VAULT, SQLException in StandardPoolDataSource:getConnection exception: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection no connection available java.lang.NullPointerException
Does this mean that its running out of active connections ? As you can see in the code, I do close the connection object in the finally statement of getChangeData() to free up the connection object