本文整理汇总了Java中org.basex.api.client.ClientSession类的典型用法代码示例。如果您正苦于以下问题:Java ClientSession类的具体用法?Java ClientSession怎么用?Java ClientSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientSession类属于org.basex.api.client包,在下文中一共展示了ClientSession类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testImportData
import org.basex.api.client.ClientSession; //导入依赖的package包/类
@Test
public void testImportData() throws Exception {
Server srv = Server.getInstance();
final URL fname = BaseXTestSuite.class.getClassLoader().getResource( "sampleHarvest.xml" );
File file = new File(fname.toURI());
srv.startup(file);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try(ClientSession session = new ClientSession(Server.SERVER_NAME, Server.PORT, "admin", "admin")) {
session.execute("SET mainmem true");
//session.execute( "SET DEBUG true" );
session.execute("SET SERIALIZER newline=\"\\n\"");
session.execute("SET SERIALIZER item-separator=\"\\n\"");
session.execute("OPEN math");
session.setOutputStream( baos );
session.query("count(./*/*)").execute();
Assert.assertEquals( "104", baos.toString( "UTF-8" ) );
session.execute( "CLOSE" );
}
}
示例2: runApp
import org.basex.api.client.ClientSession; //导入依赖的package包/类
@Override
public void runApp() throws Exception {
try (ClientSession session = new ClientSession(config.getHost(), Integer.valueOf(config.getPort()), config.getUsername(), config.getPassword())) {
try (ClientQuery query = session.query(FileUtil.readFile(config.getMainFile()))) {
for (XQueryRunnerVariable variable : config.getVariables()) {
if (variable.ACTIVE) {
query.bind(variable.NAME, variable.VALUE, variable.TYPE);
}
}
if (config.isContextItemEnabled()) {
String contextItemValue = config.isContextItemFromEditorEnabled() ? config.getContextItemText() : readFile(config.getContextItemFile());
query.context(contextItemValue, config.getContextItemType());
}
output.print(query.execute());
}
}
}
示例3: makeSession
import org.basex.api.client.ClientSession; //导入依赖的package包/类
public void makeSession() {
try {
session = new ClientSession("localhost", 1984, "admin", "admin");
} catch(Exception e){
e.printStackTrace();
System.exit(-1);
}
}