Here you will find examples demonstrating the usage of the Vert.x JDBC Client.
This example shows the basic functionality of the JDBC client, it demonstrates how to connect to a database, perform basic data definition queries by creating a test table plus test data, after it shows how to perform simple queries without parameters and shows how to close the connection.
The example is available in several languages:
-
Java: JDBCExample.java
-
JavaScript: jdbc_example.js
-
Groovy: jdbc_example.groovy
-
Ruby: jdbc_example.rb
This is a follow up to the Simple
example. In this example you will see how to write queries with parameters, the
advantage of doing so is to avoid common SQL injection security issues since all parameters are used in a
PreparedStatement
before being sent to the database engine.
The example is available in several languages:
-
Java: JDBCExample.java
-
JavaScript: jdbc_example.js
-
Groovy: jdbc_example.groovy
-
Ruby: jdbc_example.rb
The Transaction example show how to start and finish a transaction using the asynchronous jdbc client. Note that the
expected result is 1
since the example is counting the number of inserted rows after a the end of the transaction.
The example is only available in Java:
The Transaction rollback example is a modified version of the simple Transaction example. In this example after
inserting data we rollback the transaction and the final count show that we have 0
rows in our table.
The example is only available in Java: