Ultipa JDBC Driver is a Type 4 pure Java driver that enables standard SQL access to Ultipa Graph Database. It allows BI tools (such as Tableau, DBeaver, and others) and Java applications to query Ultipa using SQL statements, which are automatically translated to GQL.
Add the following dependency to your pom.xml:
XML<dependencies> <dependency> <groupId>com.ultipa</groupId> <artifactId>ultipa-jdbc-driver</artifactId> <version>1.0.0</version> </dependency> </dependencies>
For BI tools, place the JAR file in the tool's driver directory.
jdbc:ultipa://<host>:<port>/<graph>?user=<username>&password=<password>
Example:
jdbc:ultipa://10.0.0.1:60061/social?user=root&password=root
Javaimport java.sql.*; String url = "jdbc:ultipa://10.0.0.1:60061/social?user=root&password=root"; try (Connection conn = DriverManager.getConnection(url); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT name, age FROM Person WHERE age > 30")) { while (rs.next()) { System.out.println(rs.getString("name") + ": " + rs.getInt("age")); } }
When configuring Ultipa in a BI tool:
com.ultipa.jdbc.UltipaDriver.The driver automatically translates SQL SELECT statements into GQL queries:
| SQL | GQL |
|---|---|
SELECT name, age FROM Person WHERE age > 30 | MATCH (n:Person) WHERE n.age > 30 RETURN n.name, n.age |
SELECT * FROM Person ORDER BY age LIMIT 10 | MATCH (n:Person) RETURN n ORDER BY n.age LIMIT 10 |
SELECT COUNT(*) FROM Person | MATCH (n:Person) RETURN count(n) |
SELECT with column selectionWHERE with comparison operators, AND, OR, NOTORDER BY with ASC/DESCLIMIT and OFFSETCOUNT, SUM, AVG, MIN, MAXGROUP BY and HAVINGIf a statement is already valid GQL, it is passed through directly without translation:
JavaResultSet rs = stmt.executeQuery("MATCH (n:Person)-[:Knows]->(m:Person) RETURN n.name, m.name");
The SQL-to-GQL translator is also available as a standalone Java library:
Javaimport com.ultipa.sql2gql.SqlToGqlTranslator; import com.ultipa.sql2gql.GqlResult; SqlToGqlTranslator translator = new SqlToGqlTranslator(); GqlResult result = translator.translate("SELECT name, age FROM Person WHERE age > 30"); System.out.println(result.getGql()); // MATCH (n:Person) WHERE n.age > 30 RETURN n.name, n.age System.out.println(result.isPassthrough()); // false
Or as a CLI tool:
Bashjava -jar ultipa-sql2gql.jar "SELECT name FROM Person"