- exception management for SQLGrammarException adding a cause message
- method removeQueryExecution implemented and commented in class ConnectionManager git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-access/DatabasesResourcesManager@99191 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f790f715b7
commit
a2ea87687d
|
@ -51,7 +51,7 @@ public class ConnectionManager {
|
|||
} catch (Exception e) {
|
||||
System.out.println("ERROR IN DB INITIALIZATION : "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
// e.printStackTrace();
|
||||
// AnalysisLogger.getLogger().trace(e);
|
||||
}
|
||||
return dbHibConnection;
|
||||
|
@ -134,7 +134,6 @@ public class ConnectionManager {
|
|||
|
||||
ss.beginTransaction();
|
||||
|
||||
|
||||
Query qr = null;
|
||||
|
||||
// statement to check if the query is a "show create table"
|
||||
|
@ -177,6 +176,7 @@ public class ConnectionManager {
|
|||
|
||||
qr = ss.createSQLQuery(query);
|
||||
|
||||
|
||||
qr.setResultTransformer(AliasToEntityOrderedMapResultTransformer.INSTANCE);
|
||||
|
||||
// @SuppressWarnings("unchecked")
|
||||
|
@ -233,8 +233,7 @@ public class ConnectionManager {
|
|||
// "The query could not be executed: Error in retrieving a user defined type. Try to use a store procedure to convert the type");
|
||||
|
||||
AnalysisLogger.getLogger().debug(
|
||||
"In ConnectionManager-> "
|
||||
+ e.getLocalizedMessage());
|
||||
"In ConnectionManager-> " + e.getLocalizedMessage());
|
||||
|
||||
throw new Exception(e.getLocalizedMessage());
|
||||
|
||||
|
@ -242,6 +241,12 @@ public class ConnectionManager {
|
|||
|
||||
if (e instanceof org.hibernate.exception.SQLGrammarException) {
|
||||
|
||||
String cause = "";
|
||||
if (e.getCause() != null) {
|
||||
cause = e.getCause().getLocalizedMessage();
|
||||
// System.out.println(e.getCause().getLocalizedMessage());
|
||||
}
|
||||
|
||||
// System.out.println(e.getCause().getMessage());
|
||||
|
||||
// AnalysisLogger.getLogger().debug("In ConnectionManager-> ERROR The query could not be executed: SQL grammar error in the query");
|
||||
|
@ -256,10 +261,10 @@ public class ConnectionManager {
|
|||
// throw new Exception(e.getCause().getMessage());
|
||||
|
||||
AnalysisLogger.getLogger().debug(
|
||||
"In ConnectionManager-> "
|
||||
+ e.getLocalizedMessage());
|
||||
"In ConnectionManager-> " + e.getLocalizedMessage()
|
||||
+ "." + cause);
|
||||
|
||||
throw new Exception(e.getLocalizedMessage());
|
||||
throw new Exception(e.getLocalizedMessage() + "." + cause);
|
||||
|
||||
}
|
||||
|
||||
|
@ -272,8 +277,7 @@ public class ConnectionManager {
|
|||
// e.printStackTrace();
|
||||
|
||||
AnalysisLogger.getLogger().debug(
|
||||
"In ConnectionManager-> "
|
||||
+ e.getLocalizedMessage());
|
||||
"In ConnectionManager-> " + e.getLocalizedMessage());
|
||||
|
||||
throw new Exception(e.getLocalizedMessage());
|
||||
|
||||
|
@ -292,6 +296,26 @@ public class ConnectionManager {
|
|||
|
||||
}
|
||||
|
||||
// //to cancel the execution of the current query
|
||||
// public void removeQueryExecution(SessionFactory DBSessionFactory) throws Exception{
|
||||
//
|
||||
// try{
|
||||
//
|
||||
// Session ss = DBSessionFactory.getCurrentSession();
|
||||
//
|
||||
// ss.beginTransaction();
|
||||
//
|
||||
// ss.cancelQuery();
|
||||
//
|
||||
// ss.getTransaction().commit();
|
||||
//
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// throw e;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
// /** Method that creates the connection */
|
||||
// public SessionFactory createConnection(AlgorithmConfiguration config) {
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue