当前位置: 首页>>代码示例>>Java>>正文


Java CreateDB类代码示例

本文整理汇总了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();
}
 
开发者ID:wsdookadr,项目名称:mdetect,代码行数:28,代码来源:XmlStore.java

示例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;
}
 
开发者ID:physikerwelt,项目名称:mathsearch-backend-basex,代码行数:16,代码来源:Server.java

示例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());
    }
}
 
开发者ID:KinshipSoftware,项目名称:KinOathKinshipArchiver,代码行数:12,代码来源:EntityCollection.java

示例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 
    }
 
开发者ID:KinshipSoftware,项目名称:KinOathKinshipArchiver,代码行数:28,代码来源:EntityCollection.java

示例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();
    }
 
开发者ID:KinshipSoftware,项目名称:KinOathKinshipArchiver,代码行数:31,代码来源:EntityCollection.java

示例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;
}
 
开发者ID:KinshipSoftware,项目名称:KinOathKinshipArchiver,代码行数:13,代码来源:EntityCollection.java


注:本文中的org.basex.core.cmd.CreateDB类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。