Skip to content
Browse files

Added documentation for DatabaseUrlDataSource

  • Loading branch information
jkutner authored and szeiger committed Jul 29, 2015
1 parent 9725b41 commit c44e9c82e555d71967e965642df12b9f41252d86
@@ -25,6 +25,12 @@ object Connection extends App {
val db = Database.forDataSource(dataSource: javax.sql.DataSource)
if (false){
val dataSource = null.asInstanceOf[slick.jdbc.DatabaseUrlDataSource]
val db = Database.forDataSource(dataSource: slick.jdbc.DatabaseUrlDataSource)
if(false) {
val jndiName = ""
@@ -38,6 +38,27 @@ until the JVM ends (``DB_CLOSE_DELAY=-1``, which is H2 specific).

.. index:: DataSource

Using a Database URL

A Database URL, a platform independent URL in the
form ``vendor://user:password@host:port/db``,
is often provided by platforms such as Heroku.
You can use a Database URL in Typesafe Config as shown here:

.. includecode:: resources/application.conf#dburl

By default, the data source will use the value of the ``DATABASE_URL`` environment variable.
Thus you may omit the ``url`` property if the ``DATABASE_URL`` environment variable
is set. You may also define a custom environment variable with standard
Typesafe Config syntax, such as ``${?MYSQL_DATABASE_URL}``.

Or you may pass a :javaapi:`DatabaseUrlDataSource <slick/jdbc/DatabaseUrlDataSource>` object to
:api:`forDataSource <slick.jdbc.JdbcBackend$DatabaseFactoryDef@forDataSource(DataSource,AsyncExecutor,Boolean):DatabaseDef>`.

.. includecode:: code/Connection.scala#forDatabaseURL

Using a DataSource

@@ -29,3 +29,13 @@ tsql {

databaseUrl {
dataSourceClass = "slick.jdbc.DatabaseUrlDataSource"
properties = {
driver = "slick.driver.PostgresDriver$"
url = "postgres://user:pass@host/dbname"

0 comments on commit c44e9c8

Please sign in to comment.
You can’t perform that action at this time.