- 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;
|
||||
|
@ -128,13 +128,12 @@ public class ConnectionManager {
|
|||
try {
|
||||
ss = DBSessionFactory.getCurrentSession();
|
||||
|
||||
//print check added to measure the timeout
|
||||
// AnalysisLogger.getLogger().debug(
|
||||
// "In ConnectionManager-> beginTransaction: ");
|
||||
// print check added to measure the timeout
|
||||
// AnalysisLogger.getLogger().debug(
|
||||
// "In ConnectionManager-> beginTransaction: ");
|
||||
|
||||
ss.beginTransaction();
|
||||
|
||||
|
||||
|
||||
Query qr = null;
|
||||
|
||||
// statement to check if the query is a "show create table"
|
||||
|
@ -176,6 +175,7 @@ public class ConnectionManager {
|
|||
"In ConnectionManager-> executing query: " + query);
|
||||
|
||||
qr = ss.createSQLQuery(query);
|
||||
|
||||
|
||||
qr.setResultTransformer(AliasToEntityOrderedMapResultTransformer.INSTANCE);
|
||||
|
||||
|
@ -225,23 +225,28 @@ public class ConnectionManager {
|
|||
|
||||
// System.out.println(e.getClass().toString());
|
||||
|
||||
// AnalysisLogger
|
||||
// .getLogger()
|
||||
// .debug("In ConnectionManager-> ERROR The query could not be executed: Error in retrieving a user defined type. Try to use a store procedure to convert the type");
|
||||
//
|
||||
// throw new Exception(
|
||||
// "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-> ERROR The query could not be executed: Error in retrieving a user defined type. Try to use a store procedure to convert the type");
|
||||
//
|
||||
// throw new Exception(
|
||||
// "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());
|
||||
|
||||
|
||||
}
|
||||
|
||||
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");
|
||||
|
@ -249,32 +254,31 @@ public class ConnectionManager {
|
|||
// throw new
|
||||
// Exception("The query could not be executed: SQL grammar error in the query");
|
||||
|
||||
// AnalysisLogger.getLogger().debug(
|
||||
// "In ConnectionManager-> "
|
||||
// + e.getCause().getLocalizedMessage());
|
||||
//
|
||||
// throw new Exception(e.getCause().getMessage());
|
||||
|
||||
// AnalysisLogger.getLogger().debug(
|
||||
// "In ConnectionManager-> "
|
||||
// + e.getCause().getLocalizedMessage());
|
||||
//
|
||||
// throw new Exception(e.getCause().getMessage());
|
||||
|
||||
AnalysisLogger.getLogger().debug(
|
||||
"In ConnectionManager-> "
|
||||
+ e.getLocalizedMessage());
|
||||
|
||||
throw new Exception(e.getLocalizedMessage());
|
||||
"In ConnectionManager-> " + e.getLocalizedMessage()
|
||||
+ "." + cause);
|
||||
|
||||
throw new Exception(e.getLocalizedMessage() + "." + cause);
|
||||
|
||||
}
|
||||
|
||||
if (e instanceof org.hibernate.exception.GenericJDBCException) {
|
||||
|
||||
// AnalysisLogger.getLogger().debug(
|
||||
// "In ConnectionManager-> "
|
||||
// + e.getCause().toString());
|
||||
|
||||
// e.printStackTrace();
|
||||
|
||||
|
||||
// AnalysisLogger.getLogger().debug(
|
||||
// "In ConnectionManager-> "
|
||||
// + e.getCause().toString());
|
||||
|
||||
// e.printStackTrace();
|
||||
|
||||
AnalysisLogger.getLogger().debug(
|
||||
"In ConnectionManager-> "
|
||||
+ e.getLocalizedMessage());
|
||||
|
||||
"In ConnectionManager-> " + e.getLocalizedMessage());
|
||||
|
||||
throw new Exception(e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
@ -291,6 +295,26 @@ public class ConnectionManager {
|
|||
return obj;
|
||||
|
||||
}
|
||||
|
||||
// //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