本文整理匯總了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);
}