简体   繁体   English

我们可以在 Java 中使用 JDBC 驱动程序使用 Select 查询来获取顶点数据吗

[英]Can we use the Select query to get the vertex data using JDBC Driver in Java

I am trying to run select statement for tigerGraph using JDBC Driver for JAVA but getting java.sql.SQLException: Unsupported dbtable: InfectionCase Error.我正在尝试使用 JDBC Driver for JAVA 为tigerGraph 运行选择语句,但得到 java.sql.SQLException: Unsupported dbtable: InfectionCase Error。 Is select statement supported by tigerGraph using JDBC or is there any other way to execute Select Statement. TigerGraph 是否支持使用 JDBC 的 select 语句,或者是否有任何其他方式来执行 Select 语句。

try (Connection con = getConnection()) {
        String query = "select * From InfectionCase where id == \"Hansarang Convalescent Hospital\"";
        System.out.println("Running :" + query);
        Statement statement = con.createStatement();
        ResultSet rs = statement.executeQuery(query);
        System.out.println(rs.toString());
        do {
            java.sql.ResultSetMetaData metaData = rs.getMetaData();
            System.out.println("Table: " + metaData.getCatalogName(1));
            System.out.print(metaData.getColumnName(1));
            for (int i = 2; i <= metaData.getColumnCount(); ++i) {
                System.out.print("\t" + metaData.getColumnName(i));
            }

java.sql.SQLException: Unsupported dbtable: InfectionCase
at com.tigergraph.jdbc.restpp.driver.QueryParser.<init>(QueryParser.java:629)
at com.tigergraph.jdbc.restpp.RestppStatement.execute(RestppStatement.java:41)
at com.tigergraph.jdbc.restpp.RestppStatement.executeQuery(RestppStatement.java:35)
at com.prissoft.connection.GraphJSON.selectStatementUsingSQL(GraphJSON.java:145)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)

To fetch vertex instances from TigerGraph you need to use a different syntax as the SELECT statement is not supported in the JDBC driver:要从 TigerGraph 获取顶点实例,您需要使用不同的语法,因为 JDBC 驱动程序不支持SELECT语句:

try (Connection con = getConnection()) {
    String query = "get vertex(InfectionCase, \"Hansarang Convalescent Hospital\")";
    <more statements>
}

You can use this get vertex(vertex_type) syntax to get a single vertex by primary ID or get a set of vertices (optionally filtered, sorted and limited).您可以使用此get vertex(vertex_type)语法按主 ID 获取单个顶点或获取一组顶点(可选地过滤、排序和限制)。 See the documentation on this.请参阅有关此的文档

I personally think that it is better to access TigerGraph via the REST API than using the JDBC driver.我个人认为通过REST API访问 TigerGraph 比使用 JDBC 驱动更好。 JDBC was designed for relation databases and thus it expects tabular data. JDBC 是为关系数据库设计的,因此它需要表格数据。 The graph is not tabular, it's a data network.该图不是表格,它是一个数据网络。 So, what you normally get out of a TigerGraph statement or query execution is a JSON document describing a subgraph: vertices and edges.因此,您通常从 TigerGraph 语句或查询执行中得到的是描述子图的 JSON 文档:顶点和边。 This output can be flattened into rows and columns, but then you get a lesser image of the graph: a 2D projection of a 3D (or rather: a multi-dimensional) data set.这个输出可以被展平成行和列,但是你会得到一个较小的图形图像:3D(或者更确切地说:多维)数据集的 2D 投影。

Another note: fetching individual vertices and edges, or even sets of these via JDBC calls (like above) or via the built-in REST endpoints (like http://localhost:9000/graph/MyGrah/vertices/InfectionCase/Hansarang+Convalescent+Hospital ) is not the most efficient use of TigerGraph.另一个注意事项:通过 JDBC 调用(如上)或通过内置 REST 端点(如http://localhost:9000/graph/MyGrah/vertices/InfectionCase/Hansarang+Convalescent+Hospital ) 不是 TigerGraph 最有效的使用方式。 Surely, sometimes you just need a set of vertices to list in an app or visualise a graph.当然,有时您只需要一组顶点即可在应用程序中列出或可视化图表。 The real power comes from developing queries , TigerGraph's "stored procedures" that can execute even very complex and sophisticated graph algorithms like PageRank or Louvain community detection inside the graph very fast, in a parallelised fashion.真正的力量来自于开发查询,TigerGraph 的“存储过程”,它可以以并行的方式非常快速地在图中执行非常复杂和复杂的图算法,如PageRankLouvain 社区检测

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法通过我的选择查询从SQL Server获取数据(使用jdbc驱动程序) - Can't get data from a SQL Server with my select query (using jdbc driver) 如果供应商没有提供驱动程序,我们可以使用jdbc吗? - can we use jdbc if vendor has not provided driver? 如何使用 jdbc 驱动程序在 java 中正确执行“SET”查询 - how to properly execute a `SET` query in java using jdbc driver 我们可以使用gremlin-Java客户端将ResultSet中的Result转换为Vertex吗? - Can we convert Result in ResultSet to Vertex by using gremlin - java client? 为什么我们更喜欢使用Class.forName(java.mysql.jdbc.Driver)而不是新java.mysql.jdbc.Driver的jdbc驱动程序 - Why do we prefer jdbc driver using Class.forName(java.mysql.jdbc.Driver) over new java.mysql.jdbc.Driver 无法使用 JDBC 驱动程序连接到 Salesforce - Can't get connection to Salesforce using JDBC driver 在Cassandra Java驱动程序中为Select查询获取LIMIT值 - Get LIMIT value for a Select query in Cassandra java driver 如何使用JDBC在SELECT查询中使用动态表名 - How to use dynamic table name in SELECT query using JDBC 无法使用java jdbc驱动程序连接到Mysql - Cannot connect to Mysql using java jdbc Driver 在Java 1.6中使用JDBC Type 3驱动程序 - Using a JDBC Type 3 driver with Java 1.6
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM