MySQL Kotlin wrapper based on HikariCP
<dependency>
<groupId>com.sxtanna.database</groupId>
<artifactId>Kuery</artifactId>
<version>LATEST</version>
</dependency>
compile "com.sxtanna.database:Kuery:+"
1-0. To create a new instance of Kuery, you would follow this syntax
val kuery = Kuery[file: File]
val kuery = Kuery[config: KueryConfig]
final Kuery kuery = Kuery.get(file: File);
final Kuery kuery = Kuery.get(config: KueryConfig);
kuery.enable()
and
kuery.disable()
val resource = kuery.resource()
final Connection resource = kuery.resource();
Database#resource will throw an IllegalStateException if it's unable to into a resource a/o the database isn't enabled
2-1. Or you could utilize the Database's ability to automatically manage the connection with various sql functions
kuery {
create("User", "name" co VarChar.of(255, true)) // deprecated in favour of the cacheable builders
ex.
Create.table("User").co("name", VarChar(255, true))()
}
kuery.execute(task -> {
task.execute(Create.table("User").co("name", new VarChar(255, true)));
});
val createUser = Create.table("User").co("name", VarChar.of(255, true))
vs
final CreateBuilder createUser = Create.table("User").co("name", VarChar.of(255, true));
kuery {
createUser()
}
kuery.execute(task -> {
task.execute(createUser);
});