This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Table definition | |
object Cities : Table() { | |
val id = integer("id").autoIncrement().primaryKey() | |
val name = varchar("name", 50) | |
} | |
// Entity definition | |
data class City( | |
val id: Int, | |
val name: String | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage | |
transaction { | |
logger.addLogger(KotlinLoggingSqlLogger) | |
... | |
} | |
// Declaration | |
object KotlinLoggingSqlLogger : SqlLogger { | |
private val logger = KotlinLogging.logger { } | |
override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun execute(cities: List<City>) { | |
transaction { | |
Cities.batchInsertOnDuplicateKeyUpdate( cities, listOf(id, name) ) { batch, city -> | |
batch[Cities.id] = city.id | |
batch[Cities.name] = city.name | |
} | |
} | |
} | |
// The below code is just a copy-paste that should actually be in the lib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object StarWarsFilms : IntIdTable() { | |
val sequelId: Column<Int> = integer("sequel_id").uniqueIndex() | |
val name: Column<String> = varchar("name", 50) | |
val director: Column<String> = varchar("director", 50) | |
} | |
data class StarWarsFilm(val sequelId: Int, | |
val name: String, | |
val director: String) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Table definition | |
object Cities : Table() { | |
val id = integer("id").autoIncrement().primaryKey() | |
val name = varchar("name", 50) | |
val create_date = datetime(name = "create_date") | |
} | |
// Entity definition | |
data class City( | |
val id: Int, | |
val name: String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main(args: Array<String>) { | |
Database.connect("jdbc:h2:mem:test", driver = "org.h2.Driver") | |
transaction { | |
// insert new city. SQL: INSERT INTO Cities (name) VALUES ('St. Petersburg') | |
val stPeteId = Cities.insert { | |
it[name] = "St. Petersburg" | |
} get Cities.id | |
// 'select *' SQL: SELECT Cities.id, Cities.name FROM Cities |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.github.jasync.sql.db.Configuration | |
import com.github.jasync.sql.db.Connection | |
import com.github.jasync.sql.db.QueryResult | |
import com.github.jasync.sql.db.RowData | |
import com.github.jasync.sql.db.mysql.MySQLConnection | |
import com.github.jasync.sql.db.mysql.util.URLParser | |
import com.github.jasync.sql.db.util.head | |
import com.github.jasync.sql.db.util.map | |
import java.util.concurrent.CompletableFuture |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
fun `"Simple query with 1 nanosec timeout"`() { | |
withConfigurablePool(shortTimeoutConfiguration()) { pool -> | |
{ | |
val connection = pool.take().get(10, TimeUnit.SECONDS) | |
assertThat(connection.isTimeout()).isEqualTo(false) | |
assertThat(connection.isConnected()).isEqualTo(true) | |
val queryResultFuture = connection.sendQuery("select sleep(1)") | |
verifyException(TimeoutException::class.java) { | |
queryResultFuture.get(10, TimeUnit.SECONDS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
request -> { | |
mySQLClient.getConnection(res -> { | |
if (res.succeeded()) { | |
SQLConnection connection = res.result(); | |
// Got a connection | |
connection.query("SELECT 0", result -> | |
request.response().end("Got response " + result.result().getNumRows())); | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java.lang.UnsupportedOperationException: datum parameter is not supported | |
at org.osgeo.proj4j.parser.Proj4Keyword.checkUnsupported(Unknown Source) ~[proj4j-0.1.0.jar:?] | |
at org.osgeo.proj4j.parser.Proj4Keyword.checkUnsupported(Unknown Source) ~[proj4j-0.1.0.jar:?] | |
at org.osgeo.proj4j.parser.Proj4Parser.parse(Unknown Source) ~[proj4j-0.1.0.jar:?] | |
at org.osgeo.proj4j.CoordinateSystemFactory.createFromParameters(Unknown Source) ~[proj4j-0.1.0.jar:?] | |
at org.osgeo.proj4j.CoordinateSystemFactory.createFromName(Unknown Source) ~[proj4j-0.1.0.jar:?] |
OlderNewer