本文整理汇总了Java中org.basex.core.cmd.CreateDB类的典型用法代码示例。如果您正苦于以下问题:Java CreateDB类的具体用法?Java CreateDB怎么用?Java CreateDB使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CreateDB类属于org.basex.core.cmd包,在下文中一共展示了CreateDB类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDB
import org.basex.core.cmd.CreateDB; //导入依赖的package包/类
public void createDB() {
context = new Context();
try {
/* check if the database is present, otherwise throw exception */
session.execute("LIST " + dbName);
session.execute("OPEN " + dbName);
} catch (IOException e) {
String dbNotFoundErrorMessage = String.format("Database '%s' was not found.", dbName);
String exceptionMessage = e.getMessage();
if(exceptionMessage != null && exceptionMessage.equals(dbNotFoundErrorMessage)) {
try {
/*
* create database and indexes
* then select the database to be used
*/
new CreateDB(dbName,"").execute(context);
new org.basex.core.cmd.Open(dbName).execute(context);
session.execute("OPEN " + dbName);
} catch (Exception e1) {
e1.printStackTrace();
}
} else {
e.printStackTrace();
}
}
context.close();
}
示例2: importData
import org.basex.core.cmd.CreateDB; //导入依赖的package包/类
public void importData( String path ) throws IOException {
session.execute( "SET mainmem true" );
session.execute( "SET SERIALIZER newline=\"\\n\"" );
session.execute( "SET SERIALIZER item-separator=\"\\n\"" );
try {
File f = new File( path );
if ( f.isFile() ) {
path = Files.toString( f, Charsets.UTF_8 );
}
} catch ( Exception ignored ) { }
CreateDB db = new CreateDB( "math", path );
//db.execute( context );
session.execute( db );
empty = false;
}
示例3: testGlobalDatabasePath
import org.basex.core.cmd.CreateDB; //导入依赖的package包/类
static public void testGlobalDatabasePath(File databaseDirectory) throws EntityServiceException {
try {
// the db path is now set with a java system property on start up, this location dbpath "Points to the directory in which ALL databases are located."
logger.info(new Get("dbpath").execute(context));
new CreateDB("test-db").execute(context);
new Close().execute(context);
} catch (BaseXException exception2) {
BugCatcherManager.getBugCatcher().logError(exception2);
throw new EntityServiceException("Could not set the database directory: " + exception2.getMessage());
}
}
示例4: EntityCollection
import org.basex.core.cmd.CreateDB; //导入依赖的package包/类
public EntityCollection(ProjectManager projectManager, ProjectRecord projectRecord) throws EntityServiceException {
this.projectManager = projectManager;
this.projectRecord = projectRecord;
databaseName = projectRecord.getProjectUUID();
// make sure the database exists
try {
synchronized (databaseLock) {
new Open(databaseName).execute(context);
//context.close();
new Close().execute(context);
}
} catch (BaseXException baseXException) {
try {
synchronized (databaseLock) {
new CreateDB(databaseName).execute(context);
new Close().execute(context);
// new Open(databaseName).execute(context);
//updateProjectRecord();
}
} catch (BaseXException exception2) {
BugCatcherManager.getBugCatcher().logError(exception2);
throw new EntityServiceException("Could not create database:" + exception2.getMessage());
}
}
// todo: should we explicitly close the DB? putting it in the distructor would not be reliable
// todo: however now that we close via the Close() method it seems fine and the DB is not explicitly opened
}
示例5: recreateDatabase
import org.basex.core.cmd.CreateDB; //导入依赖的package包/类
public void recreateDatabase() throws EntityServiceException {
/*
* this was depricated due to inserted data being non updateable without creating duplicates,
* however we can use it again now that paths are not used to delete records but instead the identifier is used.
* */
System.out.println("recreateDatabase: " + databaseName);
try {
// System.out.println("List: " + new List().execute(context));
synchronized (databaseLock) {
new DropDB(databaseName).execute(context);
new Set("CREATEFILTER", "*.kmdi").execute(context);
new CreateDB(databaseName, projectRecord.getProjectDataFilesDirectory().toString()).execute(context);
// System.out.println("List: " + new List().execute(context));
// System.out.println("Find: " + new Find(databaseName).title());
// System.out.println("Info: " + new Info().execute(context));
// new Open(databaseName).execute(context);
// new CreateIndex("text").execute(context); // TEXT|ATTRIBUTE|FULLTEXT|PATH
// new CreateIndex("fulltext").execute(context);
// new CreateIndex("attribute").execute(context);
// new CreateIndex("path").execute(context);
// new Close().execute(context);
// context.close();
}
} catch (BaseXException exception) {
BugCatcherManager.getBugCatcher().logError(exception);
throw new EntityServiceException("Could not recreate database:" + exception.getMessage());
}
updateProjectRecord(true, false);
updateOccured();
}
示例6: createExportDatabase
import org.basex.core.cmd.CreateDB; //导入依赖的package包/类
public Context createExportDatabase(File directoryOfInputFiles, String suffixFilter, String exportDatabaseName) throws BaseXException {
if (suffixFilter == null) {
suffixFilter = "*.kmdi";
}
Context tempDbContext = new Context();
synchronized (databaseLock) {
new DropDB(exportDatabaseName).execute(tempDbContext);
new Set("CREATEFILTER", suffixFilter).execute(tempDbContext);
new CreateDB(exportDatabaseName, directoryOfInputFiles.toString()).execute(tempDbContext);
}
return tempDbContext;
}