Luka
12/07/2025, 2:27 PMobject DatabaseFactory {
fun init(application: Application) {
<http://application.log.info|application.log.info>("DB: Initializing database connection...")
val config = HikariConfig().apply {
jdbcUrl = "jdbc:<postgresql://localhost:5432/db_name>"
driverClassName = "org.postgresql.Driver"
username = "username"
password = "password"
maximumPoolSize = 10
isAutoCommit = false
transactionIsolation = "TRANSACTION_REPEATABLE_READ"
validate()
}
<http://application.log.info|application.log.info>("DB: Connecting to: ${config.jdbcUrl}")
val dataSource = HikariDataSource(config)
Database.connect(dataSource)
<http://application.log.info|application.log.info>("DB: Connected to database!")
transaction {
<http://application.log.info|application.log.info>("DB: Creating tables...")
SchemaUtils.create(UsersSchema, RefreshTokenSchema)
<http://application.log.info|application.log.info>("DB: Tables ready!")
}
<http://application.log.info|application.log.info>("DB: Database setup complete!")
}
suspend fun <T> dbQuery(block: suspend () -> T): T =
withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
suspendTransaction {
block()
}
}
}
I have this code thats trying to connect to my postgres db thats run on a docker on my machine, but i keep getting FATAL: password authentication failed for user. Im able to connect my pg admind to this postgres and also able to login trough docker into my postgres, but my code wont connect to it. I can provide the docker-compose.yml if needed or any other info. Yes I've checked and the password/username do match the ones for my databaseEmre
12/07/2025, 3:36 PMLuka
12/07/2025, 4:57 PMEmre
12/07/2025, 5:16 PMSELECT pg_current_logfile();Luka
12/07/2025, 5:36 PMLuka
12/07/2025, 7:33 PMEmre
12/08/2025, 12:49 AM-p 5432:5432 like soLuka
12/08/2025, 8:18 AMLuka
12/08/2025, 10:46 AMservices:
postgres:
image: postgres:18
container_name: boqez_db
environment:
POSTGRES_DB: ${DB_NAME}
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
ports:
- "5432:5432"
volumes:
- dbdata:/var/lib/postgresql
restart: always
volumes:
dbdata:
this is the docker file that I use with that commandLuka
12/08/2025, 10:49 AMLuka
12/08/2025, 2:23 PM