I've created a small test using 3 notations for inserting into the database:
@Test
public void testInsert() {
String sql = "INSERT INTO animals (name) VALUES ('monkey');";
connection().update(sql, onSuccess(result -> {
System.out.println(result.getKeys());
testComplete();
}));
await();
}
@Test
public void testInsert2() {
String sql = "INSERT INTO animals (name) VALUES (?);";
connection().updateWithParams(sql, new JsonArray().add("macaco"), onSuccess(result -> {
System.out.println(result.getKeys());
testComplete();
}));
await();
}
@Test
public void testInsert3() {
String sql = "INSERT INTO animals set name = ?;";
connection().updateWithParams(sql, new JsonArray().add("ape"), onSuccess(result -> {
System.out.println(result.getKeys());
testComplete();
}));
await();
}
They all inserted data and returned the correct primary key.
This is my json config:
return new JsonObject()
.put("url", "jdbc:mariadb://localhost:3306/test?user=root&password=my-secret-pw")
.put("driver_class", "org.mariadb.jdbc.Driver");
And i am using the following driver:
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>1.2.2</version>
<scope>test</scope>
</dependency>
All fine here :-/
What's your ddl, driver and connection string?