--
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/nPomE1Z-xb8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/49b05831-8b15-463f-8644-f4d4ec9103d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and all its topics, send an email to play-framework+unsubscribe@googlegroups.com.
slick.dbs.default.db.connectionTestQuery="SELECT TRUE"
Hi,
I'm at a Hackathon currently and spend like the last two hours with the Heroku-Dev Evangelist trying to get 2.4 with Slick working on Heroku with a Postgres 2.4.1 ... but we keep failing because of the JDBC4 Connection.isValid() error.
It works for me locally with 2.4.1 Postgres. We have tried all the tricks listed on https://www.playframework.com/documentation/2.4.x/Migration24
However, Play seems to ignore ALL the settings. This is in my application.conf:
# play.db.pool=bonecp
play {
db {
pool = "bonecp"
}
}
slick.dbs.default.db.pool=“bonecp"
slick.dbs.default.pool=“bonecp"
play.db.pool won’t affect what connection pool Slick is using. Furthermore, be aware that any configuration under play.db is not considered by Play Slick.slick.dbs.default.driver="slick.driver.PostgresDriver$"
slick.dbs.default.db.driver="org.postgresql.Driver"
slick.dbs.default.db.url="jdbc:postgresql://..."
slick.dbs.default.db.hikaricp.connectionTestQuery="SELECT TRUE"
slick.dbs.default.hikaricp.connectionTestQuery="SELECT TRUE”
forConfig row in the doc)
Thanks,
Christoph--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/a8ddf861-8ebe-4105-89e2-2f275ede2d67%40googlegroups.com.
Hi Mirco,
thanks for getting back. I was actually not migrating, but starting from scratch (I may migrate the other project in the future).
Thanks for confirming my suspicions regarding Slick not using any of the play.db.* configuration. This wasn't clear for me when I read the documentation (but this may just have been my fault, as during the Hackathon I tried to get this done as quickly as possible…).
HirakiCP is actually completely fine for me, I was just trying to switch to BoneCP to get anything working.
Anyway, I really have to get to work now. Will try to debug some more later today. Thanks for your help!
On Monday, June 22, 2015 at 9:28:30 AM UTC+2, Mirco Dotta wrote:
Hi,Hi Christoph,
I'm at a Hackathon currently and spend like the last two hours with the Heroku-Dev Evangelist trying to get 2.4 with Slick working on Heroku with a Postgres 2.4.1 ... but we keep failing because of the JDBC4 Connection.isValid() error.
It works for me locally with 2.4.1 Postgres. We have tried all the tricks listed onhttps://www.playframework.com/documentation/2.4.x/Migration24
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/01953236-93ad-450e-993b-52bdc2a97582%40googlegroups.com.
Hi Joe,
thanks for getting back! It works when I use a local Postgres DB and doesn't work if I use the Postgres DB provided by Heroku (also if I use Herokus DB with a local server). I'm not really sure what the difference could be, as both are supposed to be Postgres 9.4.1
You are right - if I remove the "hirakicp" the connectionTestQuery seems to be used instead! I guess this documentation:https://github.com/playframework/playframework/commit/92b9cd2594672e434ebba98b06edda02463936fbis then not applicable for Slick?
Is this any help?
It works for me locally with 2.4.1 Postgres. We have tried all the tricks listed onhttps://www.playframework.com/documentation/2.4.x/Migration24
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/58128fbd-9a31-4e90-94cc-a47198fcf185%40googlegroups.com.
To make sure I didn't mess anything up, I started from scratch with the play-scala-intro template (which already includes Slick). I did run into the same issue.
I've uploaded it to Github, so you can see my changes to the template and try for yourself: https://github.com/cneijenhuis/herokuplayslick
I also added some info for those that are new to Heroku.
If you don't want to signup to Heroku, I can also provide you with a Database URL of a Heroku instance so you can test locally, as the same error happens there. Just send me a private email, as I'm not comfortable sharing the credentials in public ;-)
If it's more appropriate, I can also open a Bug Report either with Play! or Slick, as we've got a complete example now.
On a related note, I've submitted a PR with small updates to the Play/Heroku documentation, and I'm happy to do some more documentation work once this works ;-)
Cheers,
Christoph--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/bace04c7-d83f-4881-a163-8fbe460fd06a%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/nPomE1Z-xb8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/98F6319A-FFE8-48A7-B546-84E9A6B285AD%40typesafe.com.
Try to make a database connection to the given URL. The driver should return "null" if it realizes it is the wrong kind of driver to connect to the given URL.
if (driverClassName != null) {
Enumeration<Driver> drivers = DriverManager.getDrivers();
while (drivers.hasMoreElements()) {
Driver d = drivers.nextElement();
if (d.getClass().getName().equals(driverClassName)) {
this.driver = d;
break;
}
}
if (driver == null) {
LOGGER.warn("Registered driver with driverClassName={} was not found, trying direct instantiation.", driverClassName);
try {
Class<?> driverClass = this.getClass().getClassLoader().loadClass(driverClassName);
this.driver = (Driver) driverClass.newInstance();
}
catch (Exception e) {
LOGGER.warn("Could not instantiate instance of driver class {}, trying JDBC URL resolution", driverClassName, e);
}
}
}
Just so you know, as soon as we (HikariCP) investigated this issue and discovered that the DB was rejecting the URL, we added a check (acceptUrl()) to HikariCP.
HikariCP will now report that no driver was found to accept URL 'xyz'. From our side that is probably about as much as we can do in this case, but should provide a clearer diagnostic path for the user.
Conversely, the URL is a transparent string to HikariCP, and one which the driver can accept or reject based on its own parsing, and therefore driver developers are themselves free to accept a DATABASE_URL if it reaches critical mass.
--
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/nPomE1Z-xb8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/a2deb9fd-136c-42aa-bb21-d8411a91986b%40googlegroups.com.
While we were certainly willing to address what was ostensibly was a bug in HikariCP (not asking the driver to validate the URL), we do believe the responsibility of generating a valid JDBC URL as lying above HikariCP. Conversely, the URL is a transparent string to HikariCP, and one which the driver can accept or reject based on its own parsing, and therefore driver developers are themselves free to accept a DATABASE_URL if it reaches critical mass.
Finally, and this applies more to connectionCustomizerClassName than connectionInitSql, strange as it may seem for the creators of a connection pool library, we want to avoid features that result in "pool lock-in". It should be easy for users to switch pools -- not just to HikariCP but away from HikariCP. In the case of the IConnectionCustomer, as soon as a user implements this interface and their application cannot run without its actions, they have locked their application to HikariCP. Therefore, we can say with a high degree of confidence that IConnectionCustomer and its related configuration (connectionCustomizerClassName) will be removed.
It's midnight here in Tokyo, so I haven't fully digested the proposal above, but I will note that HikariDataSource itself does implement Closeable currently. HikariCP's DriverDataSource does not currently implement Closeable, though it could if it would help you guys eliminate boilerplate.
Our primary concern for Slick users, or indeed Typesafe, would be "pool lock-in". We have seen ourselves the technical debt created by exploiting custom extensions in what should be a commodity library (a connection pool), that creates artifical barriers to moving to newer libraries for teams inhereting code several years down the line.
If a path can be found that doesn't lock you guys in (or your users), we'd be happy to take a look and help where we can.
properties {// databaseUrl = "..."
// No databaseUrl defined? HerokuDataSource will read it directly from the env variable
}
-Ddb.default.url=${DATABASE_URL}-Ddb.secondary.url=${HEROKU_POSTGRESQL_RED_URL}
While the idea of `com.zaxxer.hikari.util.HerokuDataSource` is great for Heroku, DatabaseURL is a platform independent thing, so it should probably be generalized.
DATABASE_URL is derived from the libpq standard format for Postgres connection strings[1]. Now it's used by mysql vendors and others. It's also embraced by Cloud Foundry, and other PaaS providers. So while we're discussing this in the context of Heroku, it's something that I believe should be universally supported.
Consider, for example, an application that is composed of two processes: a Java/JDBC process, and a Python process. The DATABASE_URL could be passed to both without duplicating configuration in a JDBC specific URL. At Heroku, we often recommend that you parse the DATABASE_URL into a JDBC URL in user space, but that's often impossible (such as in the case of Play where all that is set up before you have a chance to run any code). So the only alternative (as is the case for Slick) is to extract the connection config from the DATABASE_URL manually, and hard-code it into the application.conf. I consider this a bad practice.
But let's assume neither Slick nor Hikari will support DATABASE_URL (w/o the user having to change something). Play already supports DATABASE_URL for play-jdbc so it seems natural that it would be supported no matter what the underlying implementation is. How would that work?
On Monday, July 13, 2015 at 12:58:30 PM UTC-5, Christoph Whateverhuis wrote:
On Monday, July 13, 2015 at 7:18:04 PM UTC+2, Stefan Zeiger wrote:properties {
// databaseUrl = "..."
// No databaseUrl defined? HerokuDataSource will read it directly from the env variable
}
This will not work in cases where one would have several databases configured. Afaik DATABASE_URL is always set as an env variable for the primary database, but one could have additional databases. In this case it is crucial to know the env variable name and map it to the correct db config.
It would only be a default. You could still set the string directly in the config.
On 2015-07-13 23:26, Joe Kutner wrote:
While the idea of `com.zaxxer.hikari.util.HerokuDataSource` is great for Heroku, DatabaseURL is a platform independent thing, so it should probably be generalized.
DATABASE_URL is derived from the libpq standard format for Postgres connection strings[1]. Now it's used by mysql vendors and others. It's also embraced by Cloud Foundry, and other PaaS providers. So while we're discussing this in the context of Heroku, it's something that I believe should be universally supported.
What's the difference to JDBC URLs for Postgres? At first glance https://jdbc.postgresql.org/documentation/head/connect.html seems to be identical, except for the extra "jdbc:" prefix. Is it about taking standard URL-style user/password fields and translating them to parameters?
Consider, for example, an application that is composed of two processes: a Java/JDBC process, and a Python process. The DATABASE_URL could be passed to both without duplicating configuration in a JDBC specific URL. At Heroku, we often recommend that you parse the DATABASE_URL into a JDBC URL in user space, but that's often impossible (such as in the case of Play where all that is set up before you have a chance to run any code). So the only alternative (as is the case for Slick) is to extract the connection config from the DATABASE_URL manually, and hard-code it into the application.conf. I consider this a bad practice.
In an ideal world you would have a DATABASE_URL that is compatible with both, libpq and and JDBC driver, in the first place.
But let's assume neither Slick nor Hikari will support DATABASE_URL (w/o the user having to change something). Play already supports DATABASE_URL for play-jdbc so it seems natural that it would be supported no matter what the underlying implementation is. How would that work?
Play can handle this naturally for play-jdbc because it's responsible for parsing the config syntax and creating the connection pool, so it owns the syntax. For play-slick, the situation is different. The syntax is defined entirely by Slick. While it would be technically possible for play-slick to rewrite the configuration, I don't think it's a good idea. One goal of using Slick's database configuration in Play is to be able to use the same configuration for your Play app and for standalone or non-Play modules which need to access the same database. If we want to support a different way of configuring the database, it should go into Slick. Encapsulating it in a DataSource (what should be the name of the class?) makes it explicit.
On Monday, July 13, 2015 at 12:58:30 PM UTC-5, Christoph Whateverhuis wrote:
On Monday, July 13, 2015 at 7:18:04 PM UTC+2, Stefan Zeiger wrote:properties {
// databaseUrl = "..."
// No databaseUrl defined? HerokuDataSource will read it directly from the env variable
}
This will not work in cases where one would have several databases configured. Afaik DATABASE_URL is always set as an env variable for the primary database, but one could have additional databases. In this case it is crucial to know the env variable name and map it to the correct db config.
It would only be a default. You could still set the string directly in the config.