1

In Akka Projection’s documentation under offsetting in a relational database with JDBC, there is no information about how and where the configuration for establishing a connection to the relational database used should be included. I mean configs such as the username, password, or the url.

In the documentation under offset in a relational database with Slick, the following configuration is provided for the database connection, which is unclear whether it can be used for JDBC as well:

# add here your Slick db settings
  db {
    # url = "jdbc:h2:mem:test1"
    # driver = org.h2.Driver
    # connectionPool = disabled
    # keepAliveConnection = true
  }

How and where should I specify the JDBC connection parameters?

Levi Ramsey
  • 18,884
  • 1
  • 16
  • 30
zmerr
  • 534
  • 3
  • 18

1 Answers1

2

https://doc.akka.io/docs/akka-projection/current/jdbc.html#defining-a-jdbcsession

The following line in the Scala code snippet is where you can specify connection parameters:

val c = DriverManager.getConnection("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1")
  • It seems like that connection is for establishing the JDBC session used for projecting the records to. It’s not for accessing the [schema](https://doc.akka.io/docs/akka-projection/current/jdbc.html#schema) used by the projection itself. Or should the schema of projection be placed on the same JDBC database the records get projected to? – zmerr May 30 '21 at 11:31
  • I think according to "When using JdbcProjection.exactlyOnce, the JdbcSession that is passed to the handler will be used to save the offset behind the scenes. “ I need to put the schema on the same database. – zmerr May 30 '21 at 11:35
  • 1
    Yes, you have to create the schema in the database, and then establish a connection to this database in `JdbcSession`. – Michał Pawlicki May 30 '21 at 18:14