https://blogs.oracle.com/bigdataspatialgraph/an-easy-way-to-get-graph-config-in-json-for-oracle-database
プロパティグラフ機能を使うにあたり、グラフの設定を正しく実施しておくことが重要です。通常のグラフ設定には、重要な情報(データベース接続情報、グラフ名、読み取り/利用対象のプロパティなど)が含まれています。
簡単なのは、グラフ設定Javaオブジェクトを提供されているJava APIを使って構築することですが、ユーザーがグラフ設定をJSON形式で生成し、Webアプリケーションを使いたいと思うことがあるかもしれません。以下はOracle Databaseのグラフ設定をJSON形式で取得する簡単な方法です。
まず、組み込みのgroovyを起動します。
続いて、Java APIを使ってgraph configを構築します。
[oracle@groovy/]$ sh .
/gremlin-opg-rdbms
.sh
これで、JSONベースのgraph configができあがりです。
opg-oracledb> cfg = GraphConfigBuilder.forPropertyGraphRdbms().setJdbcUrl(
"jdbc:oracle:thin:@127.0.0.1:1521:orcl"
).setUsername(
"scott"
).setPassword(
"<your_password>"
).setName(
"my_graph"
).setMaxNumConnections(2).setLoadEdgeLabel(
false
).addVertexProperty(
"name"
, PropertyType.STRING,
"default_name"
).addEdgeProperty(
"cost"
, PropertyType.DOUBLE,
"1000000"
).build();
==>{
"max_num_connections"
:2,
"username"
:
"scott"
,
"db_engine"
:
"RDBMS"
,
"loading"
:{
"load_edge_label"
:
false
},
"error_handling"
:{},
"edge_props"
:[{
"name"
:
"cost"
,
"default"
:
"1000000"
,
"type"
:
"double"
}],
"vertex_props"
:[{
"name"
:
"name"
,
"default"
:
"default_name"
,
"type"
:
"string"
}],
"name"
:
"my_graph"
,
"jdbc_url"
:
"jdbc:oracle:thin:@127.0.0.1:1521:orcl"
,
"attributes"
:{},
"format"
:
"pg"
,
"password"
:
"<your_password>"
}
0 件のコメント:
コメントを投稿