本文整理汇总了Java中org.ektorp.impl.StdCouchDbInstance.createConnector方法的典型用法代码示例。如果您正苦于以下问题:Java StdCouchDbInstance.createConnector方法的具体用法?Java StdCouchDbInstance.createConnector怎么用?Java StdCouchDbInstance.createConnector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ektorp.impl.StdCouchDbInstance
的用法示例。
在下文中一共展示了StdCouchDbInstance.createConnector方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beforeClass
import org.ektorp.impl.StdCouchDbInstance; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws MalformedURLException {
HttpClient httpClient = new StdHttpClient.Builder()
.url("http://192.168.99.100:5984/")
.username("mapUser")
.password("myCouchDBSecret")
.build();
dbi = new StdCouchDbInstance(httpClient);
CouchDbConnector dbc = dbi.createConnector(CouchInjector.DB_NAME, false);
repo = new MapRepository();
repo.db = dbc;
repo.postConstruct();
debugWriter = repo.sites.mapper.writerWithDefaultPrettyPrinter();
}
示例2: initConnection
import org.ektorp.impl.StdCouchDbInstance; //导入方法依赖的package包/类
private CouchDbConnector initConnection(String dbName, String userName, String password, String host, int port, boolean enableSSL, int timeout)
{
Builder builder = new StdHttpClient.Builder()
.host(host)
.port(port)
.connectionTimeout(timeout)
.socketTimeout(timeout)
.enableSSL(enableSSL);
if(userName != null && !userName.isEmpty() && password != null && !password.isEmpty())
builder.username(userName).password(password);
dbInstance = new StdCouchDbInstance(builder.build());
if (!dbInstance.checkIfDbExists(dbName))
dbInstance.createDatabase(dbName);
CouchDbConnector couchDB = dbInstance.createConnector(dbName, true);
return couchDB;
}
示例3: connect
import org.ektorp.impl.StdCouchDbInstance; //导入方法依赖的package包/类
@Override
public void connect() throws IOException
{
StdHttpClient.Builder builder = new StdHttpClient.Builder();
if (dbUrl != null) {
try {
builder.url(dbUrl);
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e.getMessage());
}
}
if (userName != null) {
builder.username(userName);
}
if (password != null) {
builder.password(password);
}
HttpClient httpClient = builder.build();
couchInstance = new StdCouchDbInstance(httpClient);
dbConnector = couchInstance.createConnector(dbName, false);
}
示例4: before
import org.ektorp.impl.StdCouchDbInstance; //导入方法依赖的package包/类
@Before
public void before() throws Exception {
loadConfiguration();
if (isConfigured()) {
final int timeout = 8 * 1000; // 8 seconds should be more than
// enough
httpClient = new StdHttpClient.Builder().socketTimeout(timeout).host(getHostname()).build();
// set up a simple database
couchDbInstance = new StdCouchDbInstance(httpClient);
final String databaseName = getDatabaseName();
if (couchDbInstance.getAllDatabases().contains(databaseName)) {
throw new IllegalStateException("Couch DB instance already has a database called " + databaseName);
}
connector = couchDbInstance.createConnector(databaseName, true);
final String[] columnNames = new String[] { "name", "gender", "age" };
final ColumnType[] columnTypes = new ColumnType[] { ColumnType.STRING, ColumnType.CHAR,
ColumnType.INTEGER };
predefinedTableDef = new SimpleTableDef(databaseName, columnNames, columnTypes);
}
}
示例5: beforeClass
import org.ektorp.impl.StdCouchDbInstance; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws MalformedURLException {
roomOwner = "testOwner";
HttpClient httpClient = new StdHttpClient.Builder()
.url("http://127.0.0.1:5984/")
.build();
dbi = new StdCouchDbInstance(httpClient);
CouchDbConnector dbc = dbi.createConnector(CouchInjector.DB_NAME, false);
repo = new MapRepository();
repo.db = dbc;
repo.postConstruct();
debugWriter = repo.sites.mapper.writerWithDefaultPrettyPrinter();
swapRoomsAccessPolicy = new AccessCertainResourcesPolicy(Collections.singleton(SiteSwapPermission.class));
}
示例6: setup
import org.ektorp.impl.StdCouchDbInstance; //导入方法依赖的package包/类
static void setup()
{
StdHttpClient.Builder builder = new StdHttpClient.Builder();
HttpClient httpClient = builder.build();
StdCouchDbInstance instance = new StdCouchDbInstance(httpClient);
DbPath dbPath = new DbPath(TEST_DB);
if (instance.checkIfDbExists((dbPath))) {
instance.deleteDatabase(dbPath.getPath());
}
connector = instance.createConnector(TEST_DB, true);
}