本文整理汇总了Java中com.hp.hpl.jena.db.DBConnection类的典型用法代码示例。如果您正苦于以下问题:Java DBConnection类的具体用法?Java DBConnection怎么用?Java DBConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DBConnection类属于com.hp.hpl.jena.db包,在下文中一共展示了DBConnection类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveToStore
import com.hp.hpl.jena.db.DBConnection; //导入依赖的package包/类
private void saveToStore(String rdfFileName) throws ClassNotFoundException, IOException
{
String M_DBDRIVER_CLASS = "com.mysql.jdbc.Driver";
// load the the driver class
Class.forName(M_DBDRIVER_CLASS);
String dbUrl = "jdbc:mysql://" + hostName + "/" + dbName;
// create a database connection
IDBConnection conn = new DBConnection(dbUrl, userName, password, "MySQL");
// create a model maker with the given connection parameters
ModelMaker maker = ModelFactory.createModelRDBMaker(conn);
ModelRDB model = (ModelRDB) maker.openModel(modelName);
InputStream file = new FileInputStream(rdfFileName);
model.read(file,null,"N3");
file.close();
}
示例2: getRDBModel
import com.hp.hpl.jena.db.DBConnection; //导入依赖的package包/类
/**
* <p>Method that returns a new or an existing Jena RDB model</p>
* @param dbUrl - the database url
* @param dbUser - the database user
* @param dbPass - the database password
* @param dbType - the database type
* @param create - true iff a new model is to be created, false otherwise
* @return a new or an existing Jena RDB model
*/
public Model getRDBModel( String dbUrl, String dbUser, String dbPass, String dbType, boolean create )
{
//Create a database model maker
ModelMaker rdbModelMaker = ModelFactory.createModelRDBMaker( new DBConnection( dbUrl, dbUser, dbPass, dbType ) );
//If the model does not exist create a new model, else return the existing model
if( !rdbModelMaker.hasModel( "rdbModel" ) )
{
if ( create )
return rdbModelMaker.createModel( "rdbModel" );
else
return null;
}
else
return rdbModelMaker.openModel( "rdbModel" );
}
示例3: GeneNames
import com.hp.hpl.jena.db.DBConnection; //导入依赖的package包/类
public GeneNames(String u, String p, boolean clear) {
cxn = new DBConnection(host+dbName, u, p, dbType);
ModelMaker maker = ModelFactory.createModelRDBMaker(cxn);
model = maker.createModel(dbURL);
System.out.println("Connected to Model: " + dbURL);
synonymOf = model.getProperty(gnURL + "/properties#synonymOf");
value = model.getProperty(gnURL + "/properties#value");
annotationOf = model.getProperty(gnURL + "/properties#annotationOf");
}
示例4: GoDBInterface
import com.hp.hpl.jena.db.DBConnection; //导入依赖的package包/类
public GoDBInterface(String u, String p, boolean clear) {
cxn = new DBConnection(host+dbName, u, p, dbType);
ModelMaker maker = ModelFactory.createModelRDBMaker(cxn);
model = maker.createModel(dbURL);
System.out.println("Connected to Model: " + dbURL);
}