0
다음 테스트 코드를 사용 중이고 오류 (코드에 표시됨)가 나타납니다. 연결 문자열을 어떻게 설정해야합니까?quartznet-mongodb에 대한 연결 문자열을 설정하는 방법
내가 Quartz.Impl.MongoDB 1.2, 석영 2.1.2.400, MongoDB.Bson 1.9.2.235 및 사용하고 이미 연결 문자열을 설정하는 시도 MongoDB.Driver 1.9.2.235
에 "서버 = MongoDB를 : // localhost; database = quartznet; "
class Program
{
static void Main(string[] args)
{
// test that the local mongodb is working
var connectionString = "mongodb://localhost";
var client = new MongoClient(connectionString);
var server = client.GetServer();
var database = server.GetDatabase("quartznet");
var collection = database.GetCollection<Entity>("entities");
var entity = new Entity { Name = "Tom" };
collection.Insert(entity);
var id = entity.Id;
// local mongodb is working. Now try to set up a Quartz Scheduler
var properties = new NameValueCollection();
properties["quartz.scheduler.instanceName"] = "MyApplicationScheduler"; // needed if you plan to use the same database for many schedulers
properties["quartz.scheduler.instanceId"] = System.Environment.MachineName + DateTime.UtcNow.Ticks; // requires uniqueness
properties["quartz.jobStore.type"] = "Quartz.Impl.MongoDB.JobStore, Quartz.Impl.MongoDB";
/*
* From the App.Config
<connectionStrings>
<add name="quartznet-mongodb" connectionString="server=localhost;database=quartznet;" />
</connectionStrings>
*/
var scheduler = new Quartz.Impl.StdSchedulerFactory(properties).GetScheduler(); // error thrown on this line:
// Inner exception: Invalid connection string 'server=localhost;database=quartznet;'.
Console.ReadLine();
}
}
public class Entity
{
public ObjectId Id { get; set; }
public string Name { get; set; }
}