This project is a rewrite of hoverdb
Add the repository to your pom.xml
<repositories>
<repository>
<id>sultanofcardio</id>
<url>https://repo.sultanofcardio.com/artifactory/sultanofcardio</url>
</repository>
</repositories>
Or build.gradle
repositories {
maven { url "https://repo.sultanofcardio.com/artifactory/sultanofcardio" }
}
Then add a dependency
<dependency>
<groupId>com.sultanofcardio</groupId>
<artifactId>hoverdb2</artifactId>
<version>1.0.1</version>
</dependency>
implementation 'com.sultanofcardio:hoverdb2:1.0.1'
The core library doesn't provide any specific database support out of the box. Vendor database support can be found in the following packages:
Vendor | artifact |
---|---|
MySQL | hoverdb2-mysql |
PostgreSQL | hoverdb2-postgresql |
H2 | hoverdb2-h2 |
Oracle | hoverdb2-oracle |
SQLite | hoverdb2-sqlite |
SQLServer | hoverdb2-sqlserver |
Vendor support packages have the same version as the core library and can be used in place of it. Instead of the above, you would just have:
implementation 'com.sultanofcardio:hoverdb2-h2:1.0.1'
Using the H2 vendor package, we can create an in-memory database
val h2 = H2.Memory("h2db")
You can perform normal CRUD operations with the database object
h2.select("name")
.from("my_table")
.whereEquals("id", 45)
.execute { resultSet ->
prinln(resultSet.getString("name"))
}
which is the equivalent of
SELECT name FROM my_table where id = 45;
You can also run raw SQL directly on the database
h2.run("DELETE FROM my_table WHERE id = 45")
If support for you your target database is not included, you can add it by implementing the Database
interface
class MyCustomDatabase: Database<MyCustomDatabase> {
//...
}
This library uses Semantic Versioning