From: Lourens v. d. M. <lo...@cs...> - 2009-11-07 19:12:27
|
Hi, I am having the following problem: Using the latest 5.0.12 version I do: sparql insert into graph <gr> { <http://id> <http://www.w3.org/2004/02/skos/core#prefLabel> 'test eng1'@nl .} sparql PREFIX skos: <http://www.w3.org/2004/02/skos/core#> SELECT ?value from <gr> WHERE {<http://id> skos:prefLabel ?value. FILTER regex(str(?value),"test","i")} through the jdbc4 driver from java and I get no results when expecting them. The query without the "i" argument does give the correct result. I get the correct result with the "i" option when testing through isql and the 8890/sparql connection. I add the java code illustrating this problem: On my installation the first query gives 1 result. The second query gives 0 results. Could you tell me what is wrong? Thanks, Lourens ==============TestRegex.java======================== import java.sql.*; import virtuoso.jdbc4.*; public class TestRegex { public static void main(String argv[]) { try { String urlDB = "jdbc:virtuoso://localhost:1111/charset=UTF-8"; Class.forName("virtuoso.jdbc4.Driver"); Connection conn = DriverManager.getConnection(urlDB,"dba","dba"); Statement st = conn.createStatement(); st.execute("sparql clear graph <gr>"); st.execute("sparql insert into graph <gr> { <http://id> <http://www.w3.org/2004/02/skos/core#prefLabel> 'test eng1'@nl .}"); System.out.println("##### exec query regex without i###############"); String query1 = "sparql PREFIX skos: <http://www.w3.org/2004/02/skos/core#> \nSELECT ?value from <gr> \nWHERE {<http://id> skos:prefLabel ?value. FILTER regex(str(?value),\"test\")}"; System.out.println("Running query:\n"+query1); execQuery(st,query1); System.out.println("##### exec query regex with i###################"); String query2 = "sparql PREFIX skos: <http://www.w3.org/2004/02/skos/core#> \nSELECT ?value from <gr> \nWHERE {<http://id> skos:prefLabel ?value. FILTER regex(str(?value),\"test\",\"i\")}"; System.out.println("Running query:\n"+query2); execQuery(st,query2); conn.close(); } catch (Exception e) { System.out.println(e); System.out.println("==========================================================="); e.printStackTrace(); } } public static void execQuery(Statement st, String query) throws SQLException { ResultSet rs; ResultSetMetaData rsmd; rs = st.executeQuery(query); rsmd = rs.getMetaData(); if (rsmd == null) System.out.println("getMetaData() == NULL"); int results = 0; while(rs.next()) { Object o; System.out.println(" ============= < ROW > ============ "); for (int i = 1; i <= rsmd.getColumnCount(); i++) { results++; String s = rs.getString(i); o = rs.getObject(i); if (rs.wasNull()) System.out.println(i+" ==> NULL"); else { if (o instanceof VirtuosoExtendedString) { VirtuosoExtendedString vs = (VirtuosoExtendedString)o; System.out.print("VirtuosoExtendedString: [iri="+vs.iriType+"]"); } else if (o instanceof VirtuosoRdfBox) { VirtuosoRdfBox rb = (VirtuosoRdfBox)o; System.out.print("VirtuosoRdfBox:[rdf="+rb+"; type="+rb.getType()+";lang="+rb.getLang()+"]"); } else { System.out.print(" |"); System.out.print(""+o.getClass()+"|"); } System.out.println(" ==> ["+ o + "]"); } } } System.out.println("got "+results + " results"); } } |