-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SingleConnection wrapper publish non osgi jar
- Loading branch information
1 parent
1b60933
commit b647f59
Showing
8 changed files
with
61 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/kotlin/sqlbuilder/pool/SingleConnectionDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package sqlbuilder.pool | ||
|
||
import java.io.PrintWriter | ||
import java.sql.Connection | ||
import java.util.logging.Logger | ||
import javax.sql.DataSource | ||
|
||
/** | ||
* Adapter to use SqlBuilder with an externally provided sql Connection. | ||
* Will not close the target connection. | ||
*/ | ||
public class SingleConnectionDataSource(val target: Connection) : DataSource { | ||
override fun getConnection(): Connection? { | ||
return NonClosingConnection(target) | ||
} | ||
|
||
override fun getConnection(username: String?, password: String?): Connection? { | ||
return connection | ||
} | ||
|
||
override fun setLogWriter(out: PrintWriter?) { | ||
throw UnsupportedOperationException() | ||
} | ||
|
||
override fun getLogWriter(): PrintWriter? { | ||
throw UnsupportedOperationException() | ||
} | ||
|
||
override fun setLoginTimeout(seconds: Int) { | ||
throw UnsupportedOperationException() | ||
} | ||
|
||
override fun getParentLogger(): Logger? { | ||
throw UnsupportedOperationException() | ||
} | ||
|
||
override fun getLoginTimeout(): Int { | ||
throw UnsupportedOperationException() | ||
} | ||
|
||
override fun isWrapperFor(iface: Class<*>?): Boolean { | ||
throw UnsupportedOperationException() | ||
} | ||
|
||
override fun <T : Any?> unwrap(iface: Class<T>?): T { | ||
throw UnsupportedOperationException() | ||
} | ||
} | ||
|
||
private class NonClosingConnection(private val connection: Connection) : Connection by connection { | ||
override fun close() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters