~ fix the access to the default configuration file + error message more readable in case of malformed generated SQL query
--- a/sparql2sqlendpoint/src/main/resources/default-config.json Wed Nov 03 15:36:16 2010 -0400
+++ b/sparql2sqlendpoint/src/main/resources/default-config.json Wed Nov 03 15:58:58 2010 -0400
@@ -10,13 +10,12 @@
"ui": {
"stemuri": "http://foo.example/DB/",
"sparql-query": "
-PREFIX asgn: <http://foo.example/DB/TaskAssignments#>
-PREFIX proj: <http://foo.example/DB/Projects#>
-SELECT ?lead
+PREFIX addr: <http://foo.example/DB/Addresses#>
+PREFIX pple: <http://foo.example/DB/People#>
+SELECT ?who ?city
WHERE {
- ?assignment asgn:worker <http://foo.example/DB/People/ID.7#record> .
- ?assignment asgn:project_deptName_deptCity ?project .
- ?project proj:lead ?lead .
+ ?who pple:addr ?addr .
+ ?addr addr:city ?city .
}
"
},
--- a/sparql2sqlendpoint/src/main/scala/Servlet.scala Wed Nov 03 15:36:16 2010 -0400
+++ b/sparql2sqlendpoint/src/main/scala/Servlet.scala Wed Nov 03 15:58:58 2010 -0400
@@ -32,12 +32,16 @@
/** Executes the SQL and processes the result set using the specified function. */
private def query[B](connection: Connection, sql: String)(process: ResultSet => B): B =
- using (connection) { connection =>
- using (connection.createStatement) { statement =>
- using (statement.executeQuery(sql)) { results =>
- process(results)
+ try {
+ using (connection) { connection =>
+ using (connection.createStatement) { statement =>
+ using (statement.executeQuery(sql)) { results =>
+ process(results)
+ }
}
}
+ } catch {
+ case e => throw new Exception("Malformed SQL query: \n" + sql, e)
}
/** Executes the SQL and uses the process function to convert each row into a T. */
@@ -102,8 +106,8 @@
def getConnection():Connection =
DriverManager.getConnection(config("db.url").as[String],
- config("config.user").as[String],
- config("config.password").as[String])
+ config("db.user").as[String],
+ config("db.password").as[String])
val defaultStemURI:String = config("ui.stemuri").as[String]
@@ -187,7 +191,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>{ title }</title></head>
<body>
- <h1>Request the <a href="http://www.w3.org/2001/sw/rdb2rdf/directGraph/">Direct Mapping</a> using SPARQL!</h1>
+ <h1>Query the <a href="http://www.w3.org/2001/sw/rdb2rdf/directGraph/">Direct Graph</a> using SPARQL!</h1>
<form action="sparql">
<p>
StemURI: <input cols="80" name="stemuri" id="stemuri" value={ defaultStemURI } /><br />