}
con.setAutoCommit(true);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new DBException(e.getMessage());
}
} else if (cashAvailable >= 0 && (availableStock == quantity)) {
try {
con.setAutoCommit(false);
if (setUserCash(userId, cashAvailable)
&& addUserStock(userId, stockId, availableStock)) {
con.commit();
} else {
con.rollback();
}
con.setAutoCommit(true);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new DBException(e.getMessage());
}
} else {
return false;
}
return true;