Advertisement
Guest User

Untitled

a guest
Aug 4th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. OClient.CreateDatabasePool(
  2. "127.0.0.1",
  3. 2424,
  4. "TestDatabaseName",
  5. ODatabaseType.Graph,
  6. "admin",
  7. "admin",
  8. 10,
  9. "myTestDatabaseAlias");
  10.  
  11. com.orientechnologies.orient.core.exception.OConfigurationException: Database 'TestManualy' is not configured on server (home=E:/orientdb-community-2.1.16/databases/)
  12.  
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Threading.Tasks;
  18. using Orient.Client;
  19.  
  20. namespace OrientTestCreateDB
  21.  
  22. {
  23. class CreateDB
  24.  
  25. {
  26.  
  27. private static string _hostname = "127.0.0.1";
  28. private static int _port = 2424;
  29. private static string _rootUserName = "root";
  30. private static string _rootUserPassword = "root";
  31.  
  32. private static OServer _server;
  33.  
  34. private static string _DBname = "TestDatabaseName";
  35. private static string _username = "admin";
  36. private static string _password = "admin";
  37.  
  38. static void Main(string[] args)
  39.  
  40. {
  41.  
  42. _server = new OServer(_hostname, _port, _rootUserName, _rootUserPassword);
  43.  
  44. //If the DB already exists I delete it
  45. if (_server.DatabaseExist(_DBname, OStorageType.PLocal))
  46.  
  47. {
  48.  
  49. _server.DropDatabase("TestDatabaseName", OStorageType.PLocal);
  50.  
  51. Console.WriteLine("Database " + _DBname + " deleted");
  52.  
  53. }
  54.  
  55. //Creating the new DB
  56. _server.CreateDatabase(_DBname, ODatabaseType.Graph, OStorageType.PLocal);
  57.  
  58. Console.WriteLine("Database " + _DBname + " created");
  59.  
  60. //Connect to the DB and populate it
  61. OClient.CreateDatabasePool(
  62. "127.0.0.1",
  63. 2424,
  64. _DBname,
  65. ODatabaseType.Graph,
  66. _username,
  67. _password,
  68. 10,
  69. "myTestDatabaseAlias"
  70. );
  71.  
  72. Console.WriteLine("Connected to the DB " + _DBname);
  73.  
  74. using (ODatabase database = new ODatabase("myTestDatabaseAlias"))
  75.  
  76. {
  77.  
  78. database
  79. .Create.Class("TestClass")
  80. .Extends<OVertex>()
  81. .Run();
  82.  
  83. OVertex createdVertex = database
  84. .Create.Vertex("TestClass")
  85. .Set("name", "LucaS")
  86. .Run();
  87.  
  88. Console.WriteLine("Created vertex with @rid " + createdVertex.ORID);
  89.  
  90. }
  91.  
  92. }
  93.  
  94. }
  95.  
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement