打算写一个sesame数据库的使用系列文章。这是第二篇,第一篇详见这里,讲解sesame数据库的搭建。 Sesame数据库添加triple三元组的方法有很多种,这里讲解两种,即单条添加与批量添加。 1. 建立数据库链接 Sesame数据库提供了几种数据存储办法,有本地数据库N
打算写一个sesame数据库的使用系列文章。这是第二篇,第一篇详见这里,讲解sesame数据库的搭建。
Sesame数据库添加triple三元组的方法有很多种,这里讲解两种,即单条添加与批量添加。
全自动化、全智能的在线方式管理、维护、更新的网站管理系统主要功能如下:一、系统管理:管理员管理,可以新增管理员及修改管理员密码;数据库备份,为保证您的数据安全本系统采用了数据库备份功能;上传文件管理,管理你增加产品时上传的图片及其他文件。二、企业信息:可设置修改企业的各类信息及介绍。 三、产品管理:产品类别新增修改管理,产品添加修改以及产品的审核。四、订单管理:查看订单的详细信息及订单处理。 五、
0
private Repository repo; private MemoryStore memStore; private NativeStore natStore; private File repoFile; private RepositoryConnection repoConn;
/**
* To get the repository within memory.
*/
public RepoUtil() {
repoFile = new File(Const.repoPath);
memStore = new MemoryStore();
repo = new SailRepository(memStore);
}
/**
* To get the repository on the disk.
* @param repoPath the repository file path
*/
public RepoUtil(String repoPath) {
repoFile = new File(repoPath);
natStore = new NativeStore(repoFile);
repo = new SailRepository(natStore);
}
/**
* To get the repository on the Http server.
* @param server the server address
* @param repoId the repository ID
*/
public RepoUtil(String server, String repoId) {
repo = new HTTPRepository(server, repoId);
}
try {
repo.initialize();
repoConn = repo.getConnection();//Get the connection from repository connection pool
// repoConn.setAutoCommit(false);//why deprecate the setAutoCommit method?
} catch(RepositoryException e) {
e.printStackTrace();
}ValueFactory valueFactory = new ValueFactoryImpl();
/**
* To get the URI of the specific string value
* 1. if it is already a URI, then return;
* 2. else translate it to URI format and return.
* @param iden
* @return the true URI
*/
public URI getUri(String iden) {
URI rtn = null;
String url = null;
StringBuilder strRtn = new StringBuilder(uriBuilder);
if(isUri(iden)) {
System.out.println("isUri");
return valueFactory.createURI(iden);
} else {
try {
url = URLEncoder.encode(iden,"utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
strRtn.append(url);
rtn = valueFactory.createURI(strRtn.toString());
return rtn;
}
}
/**
* To justify if the input string is
* in the format of URI.
* @param obj
* @return
*/
public boolean isUri(String obj) {
return obj.matches("(([a-zA-Z][0-9a-zA-Z+\\-\\.]*:)?/{0,2}[0-9a-zA-Z;/?:@&=+$\\.\\-_!~*'()%]+)?(#[0-9a-zA-Z;/?:@&=+$\\.\\-_!~*'()%]+)?");
// return false;
}URI creativeWork = vf.createURI(namespace+"CreativeWork"); Literal about = vf.createLiteral(namespace+"about#"+"SomeString");
/**
* The URI-URI-Literal format SPO record.
*/
public void addRecord(URI subj, URI pred, Literal obj) {
try {
// repoConn = repo.getConnection();
repoConn.add(subj, pred, obj);
// repoConn.close();
} catch (RepositoryException e) {
e.printStackTrace();
}
}
/**
* The URI-URI-URI format SPO record.
*/
public void addRecord(URI subj, URI pred, URI obj) {
try {
// repoConn = repo.getConnection();
repoConn.add(subj, pred, obj);
// repoConn.close();
} catch (RepositoryException e) {
e.printStackTrace();
}
}
File importFile = new File("segment"+j+".ttl");
String baseURI = "http://rk.com/import/test/";
RepositoryConnection con;
try {
FileReader fileReader = new FileReader(importFile);
BufferedReader reader = new BufferedReader(fileReader);
con = repo.getConnection();
con.add(reader, baseURI, RDFFormat.TURTLE);
System.out.println("Add "+j+" ends.");
con.close();
} catch (RepositoryException e) {
e.printStackTrace();
} catch (RDFParseException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号