當前位置: 首頁>>代碼示例>>Java>>正文


Java DBConnection類代碼示例

本文整理匯總了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();
}
 
開發者ID:therelaxist,項目名稱:spring-usc,代碼行數:19,代碼來源:PublishRDFCommand.java

示例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" );
}
 
開發者ID:vaibhavkhadilkar,項目名稱:D2RQ-Update,代碼行數:26,代碼來源:RDBModelForD2RQRW.java

示例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");
}
 
開發者ID:shaunmahony,項目名稱:multigps-archive,代碼行數:11,代碼來源:GeneNames.java

示例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);
}
 
開發者ID:shaunmahony,項目名稱:multigps-archive,代碼行數:7,代碼來源:GoDBInterface.java


注:本文中的com.hp.hpl.jena.db.DBConnection類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。