Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading from 0.17.7 to 0.25.1 leading to overload resolution ambiguity #938

Closed
KushalP opened this issue Jun 2, 2020 · 1 comment
Closed

Comments

@KushalP
Copy link
Contributor

KushalP commented Jun 2, 2020

I am trying to upgrade from Exposed however when bumping the version I'm seeing the following error in IntelliJ when I do:

Overload resolution ambiguity. All these functions match.
public final fun connect(datasource: ConnectionPoolDataSource, setupConnection: (Connection) → Unit = ..., manager: (Database) → TransactionManager = ...): Database defined in org.jetbrains.exposed.sql.Database.Companion
public final fun connect(datasource: DataSource, setupConnection: (Connection) → Unit = ..., manager: (Database) → TransactionManager = ...): Database defined in org.jetbrains.exposed.sql.Database.Companion

I'm using a org.apache.tomcat.jdbc.pool.DataSource which implements both javax.sql.DataSource and javax.sql.ConnectionPoolDataSource leading to the error. Casting it to one or the other doesn't appear to work.

Reproducing behaviour

Here is how I'm using Exposed in 0.17.7:

import org.apache.tomcat.jdbc.pool.DataSource
import org.apache.tomcat.jdbc.pool.PoolProperties
import org.jetbrains.exposed.sql.Database

class SampleDatabase : AutoCloseable {
    private val dataSource: DataSource

    constructor(
        interceptors: List<String> = listOf(
            "org.apache.tomcat.jdbc.pool.interceptor.ConnectionState",
            "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer",
            "com.amazonaws.xray.sql.postgres.TracingInterceptor"
        )
    ) {
        dataSource = DataSource().apply {
            poolProperties = PoolProperties().apply {
                url = "url"
                driverClassName = "org.postgresql.Driver"
                username = "user"
                password = "pass"
                validationQuery = "SELECT 1"
                jdbcInterceptors = if (interceptors.isEmpty()) null else interceptors.joinToString(";")
            }
        }
        dataSource.createPool()
        Database.connect(dataSource)
    }

    override fun close() = dataSource.close()
}

How would you expect to use a PostgreSQL connection pool with Exposed? Is there a sample of this anywhere I can refer to?

Tapac added a commit that referenced this issue Jun 4, 2020
@Tapac
Copy link
Contributor

Tapac commented Jun 4, 2020

Thank you for the report. I will replace connect with connectPool. Will be available in the next release.

@Tapac Tapac closed this as completed Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants