Strabon

changeset 232:ed6dabab362c

close strabon connection only when strabon is not NULL (in main classes of PostGIS)
author Babis Nikolaou <charnik@di.uoa.gr>
date Sun Jun 03 14:32:59 2012 +0300 (2012-06-03)
parents 97c7efb8a600
children af3620c85771
files runtime/src/main/java/eu/earthobservatory/runtime/postgis/DescribeOp.java runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryDir.java runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryOp.java runtime/src/main/java/eu/earthobservatory/runtime/postgis/StoreOp.java runtime/src/main/java/eu/earthobservatory/runtime/postgis/UpdateOp.java
line diff
     1.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/DescribeOp.java	Sun Jun 03 14:28:01 2012 +0300
     1.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/DescribeOp.java	Sun Jun 03 14:32:59 2012 +0300
     1.3 @@ -35,7 +35,6 @@
     1.4  		String outFile = args[6];
     1.5  		
     1.6  		Strabon strabon = null;
     1.7 -		
     1.8  		try {
     1.9  			strabon = new Strabon(db, user, passwd, port, host, true);
    1.10  			strabon.describe(queryString, strabon.getSailRepoConnection(), outFile);
    1.11 @@ -44,7 +43,9 @@
    1.12  			logger.error("[Strabon.DescribeOp] Error during execution of DESCRIBE query.", e);
    1.13  			
    1.14  		} finally {
    1.15 -			strabon.close();
    1.16 +			if (strabon != null) {
    1.17 +				strabon.close();
    1.18 +			}
    1.19  		}
    1.20  	}
    1.21  }
     2.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryDir.java	Sun Jun 03 14:28:01 2012 +0300
     2.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryDir.java	Sun Jun 03 14:32:59 2012 +0300
     2.3 @@ -79,27 +79,4 @@
     2.4  		}
     2.5  		return stringBuilder.toString();
     2.6  	}
     2.7 -
     2.8 -	/*
     2.9 -	private static void query(String queryString, SailRepositoryConnection con) throws MalformedQueryException, RepositoryException, QueryEvaluationException, IOException, ClassNotFoundException, TupleQueryResultHandlerException {
    2.10 -		TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
    2.11 -
    2.12 -		System.out.println(queryString);
    2.13 -		TupleQueryResult result = tupleQuery.evaluate();
    2.14 -
    2.15 -		System.out.println("-------------------------------------------");
    2.16 -		System.out.println("-                RESULTS                  -");
    2.17 -		System.out.println("-------------------------------------------");
    2.18 -
    2.19 -		tupleQuery.evaluate(new SPARQLResultsXMLWriter(System.out));
    2.20 -
    2.21 -		List<String> bindingNames = result.getBindingNames();
    2.22 -		while (result.hasNext()) {
    2.23 -			BindingSet bindingSet = result.next();			
    2.24 -			System.out.println(bindingSet.toString());
    2.25 -		}
    2.26 -		System.out.println("-------------------------------------------");
    2.27 -		System.out.flush();
    2.28 -	}
    2.29 -	 */
    2.30  }
     3.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryOp.java	Sun Jun 03 14:28:01 2012 +0300
     3.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryOp.java	Sun Jun 03 14:32:59 2012 +0300
     3.3 @@ -48,29 +48,9 @@
     3.4  			logger.error("[Strabon.QueryOp] Error during querying.", e);
     3.5  			
     3.6  		} finally {
     3.7 -			strabon.close();
     3.8 +			if (strabon != null) {
     3.9 +				strabon.close();
    3.10 +			}
    3.11  		}
    3.12  	}
    3.13 -	/*
    3.14 -	private static void query(String queryString, SailRepositoryConnection con) throws MalformedQueryException, RepositoryException, QueryEvaluationException, IOException, ClassNotFoundException, TupleQueryResultHandlerException {
    3.15 -		TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
    3.16 -
    3.17 -		System.out.println(queryString);
    3.18 -		TupleQueryResult result = tupleQuery.evaluate();
    3.19 -
    3.20 -		System.out.println("-------------------------------------------");
    3.21 -		System.out.println("-                RESULTS                  -");
    3.22 -		System.out.println("-------------------------------------------");
    3.23 -
    3.24 -		tupleQuery.evaluate(new SPARQLResultsXMLWriter(System.out));
    3.25 -
    3.26 -		List<String> bindingNames = result.getBindingNames();
    3.27 -		while (result.hasNext()) {
    3.28 -			BindingSet bindingSet = result.next();			
    3.29 -			System.out.println(bindingSet.toString());
    3.30 -		}
    3.31 -		System.out.println("-------------------------------------------");
    3.32 -		System.out.flush();
    3.33 -	}
    3.34 -	 */
    3.35  }
     4.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/StoreOp.java	Sun Jun 03 14:28:01 2012 +0300
     4.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/StoreOp.java	Sun Jun 03 14:32:59 2012 +0300
     4.3 @@ -46,7 +46,9 @@
     4.4  			logger.error("[Strabon.StoreOp] Error during store.", e);
     4.5  			
     4.6  		} finally {
     4.7 -			strabon.close();
     4.8 +			if (strabon != null) {
     4.9 +				strabon.close();
    4.10 +			}
    4.11  		}
    4.12  	}
    4.13  
     5.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/UpdateOp.java	Sun Jun 03 14:28:01 2012 +0300
     5.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/UpdateOp.java	Sun Jun 03 14:32:59 2012 +0300
     5.3 @@ -40,7 +40,9 @@
     5.4  			logger.error("[Strabon.UpdateOp] Error during execution of UPDATE query.", e);
     5.5  			
     5.6  		} finally {
     5.7 -			strabon.close();
     5.8 +			if (strabon != null) {
     5.9 +				strabon.close();
    5.10 +			}
    5.11  		}
    5.12  	}
    5.13  }