Skip to content

Commit 9275f0d

Browse files
committed
adds extended documentation about usaged of named JNDI datasources
1 parent d2b458e commit 9275f0d

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎slick/src/main/scala/slick/jdbc/JdbcBackend.scala‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,21 @@ trait JdbcBackend extends RelationalBackend {
9696
forSource(new DataSourceJdbcDataSource(ds, keepAliveConnection, maxConnections), executor)
9797

9898
/** Create a Database based on the JNDI name of a DataSource.
99+
*
100+
* NOTE: this method will return a Slick [[DatabaseDef]] configured to use the
101+
* named [[DataSource]] and the passed [[AsyncExecutor]].
102+
* Calling this method more then once for the same [[DataSource]] name, will
103+
* result in different [[DatabaseDef]]s configured with different [[AsyncExecutor]]s
104+
* but backed by the same [[DataSource]]. This is probably not what you want.
105+
* Therefore, it's recommended to call it only once and re-use the returned [[DatabaseDef]] whenever needed.
106+
* Each [[DataSource]] should be associated with only one [[AsyncExecutor]].
99107
*
100108
* @param name The name of the DataSource to use.
101109
* @param maxConnections The maximum number of connections that the DataSource can provide. This is necessary to
102110
* prevent deadlocks when scheduling database actions. Use `None` if there is no hard limit.
103111
* @param executor The AsyncExecutor for scheduling database actions.
104112
*/
105-
def forName(name: String, maxConnections: Option[Int], executor: AsyncExecutor = null) =
113+
def forName(name: String, maxConnections: Option[Int], executor: AsyncExecutor = null): DatabaseDef =
106114
new InitialContext().lookup(name) match {
107115

108116
case ds: DataSource =>

0 commit comments

Comments
 (0)