1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
protected void executeUpdate(String querry)throws FmkStoreException ,FmkSystemException{
Statement stmt =null;
FmkConnectionInterface conn = null;
try {
// on recupere la connexion qui existe peut etre deja
conn = ConnectionManager.getFmkConnection(getDataBaseName());
stmt = conn.createStatement();
// on lance la requete
int res = stmt.executeUpdate(querry.toString());
if (conn.getCommitMode() == conn.MODE_CONNECTION_AUTO)
conn.commit();
if (res == 0)
throw new FmkStoreException("EJB-4101",querry+" : Execute Update returned 0");
} catch (SQLException exception) {
String errorMessage = "";
while (exception != null) {
errorMessage += "\nERROR:\n";
errorMessage += "Message: "+ exception.getMessage ();
errorMessage += "SQLState: "+ exception.getSQLState ();
errorMessage += "ErrorCode: "+ exception.getErrorCode ();
exception = exception.getNextException();
}
throw new FmkStoreException("EJB-4202",querry+" : "+errorMessage);
}finally{
// fermeture du statement
try{
stmt.close();
}catch(Exception sqle){}
if (conn.getCommitMode() == conn.MODE_CONNECTION_AUTO){
try{
conn.close();
}catch(Exception sqle){}
}
}
} |
Partager