首 页 行业热点 新车 试驾评测 养车用车 车型库

芝麻信用负面记录会影响到征信吗

发布网友

我来回答

1个回答

懂视网

Sesame数据库利用Java API查询数据与修改数据。 1. 查询数据 获取查询数据(通过SPARQL) public static void testQuery() {try { RepositoryConnection con = repo.getConnection(); try { String queryString = PREFIX rk:http://rk.com/test/ + SELECT ?s

Sesame数据库利用Java API查询数据与修改数据。

1. 查询数据

获取查询数据(通过SPARQL)
	public static void testQuery() {
		try {
			 RepositoryConnection con = repo.getConnection();
			 try {
				 String queryString = "PREFIX rk: " +
				 		"SELECT ?s ?o " +
				 		"WHERE { " +
				 		"?s rk:type rk:CreativeWork ." +
				 		"?s ?p ?o ." +
				 		"} ";
				 TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
				 long startTime = System.currentTimeMillis();
				 TupleQueryResult result = tupleQuery.evaluate();
				 long secondTime = System.currentTimeMillis();
				 
				 List bindingNames = result.getBindingNames(); //get the name of binded variables
				 while (result.hasNext()) {
				 BindingSet bindingSet = result.next();
				 Value firstValue = bindingSet.getValue("s"); //bindingSet.getValue(bindingNames.get(0));
				 Value secondValue = bindingSet.getValue("o"); //bindingSet.getValue(bindingNames.get(1));
				 System.out.println(firstValue);
				 System.out.println(secondValue);
				 // do something interesting with the values here...
				 }
				 long endTime = System.currentTimeMillis();
				 System.out.println("evaluation time = "+(secondTime-startTime));
				 System.out.println("fetch time = "+(endTime-secondTime));
			 }
			 finally {
			 con.close();
			 }
			}
			catch (OpenRDFException e) {
			 // handle exception
				e.printStackTrace();
			}
	}

2. 修改数据

	public static void updateQuery() {
		String updateQuery = "PREFIX rk: " +
				"DELETE { " +
				"?creativeWork rk:type ?type ." +
				"} " +
				"INSERT { " +
				"?creativeWork rk:type ?typeUri ." +
				"} " +
				"WHERE { " +
				"?creativeWork rk:type ?type ." +
				"BIND( URI(?type) AS ?typeUri ) " +
				"} ";
		RepositoryConnection conn;
		try {
			conn = repo.getConnection();
			Update update = conn.prepareUpdate(QueryLanguage.SPARQL, updateQuery);
			update.execute();
			conn.commit();
			conn.close();
		} catch (RepositoryException e) {
			e.printStackTrace();
		} catch (MalformedQueryException e) {
			e.printStackTrace();
		} catch (UpdateExecutionException e) {
			e.printStackTrace();
		}
		
	}

具体SPARQL语言可以参考书籍《Learning SPARQL》。

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com