1 package com.github.davidmoten.rx.jdbc;
2
3 import java.sql.Connection;
4 import java.sql.SQLException;
5
6 import javax.sql.DataSource;
7
8 import com.github.davidmoten.rx.jdbc.exceptions.SQLRuntimeException;
9
10
11
12
13 public class ConnectionProviderFromDataSource implements ConnectionProvider {
14
15 private final DataSource dataSource;
16
17
18
19
20
21
22 public ConnectionProviderFromDataSource(DataSource dataSource) {
23 this.dataSource = dataSource;
24 }
25
26 @Override
27 public Connection get() {
28 try {
29 return dataSource.getConnection();
30 } catch (SQLException e) {
31 throw new SQLRuntimeException(e);
32 }
33 }
34
35 @Override
36 public void close() {
37
38 }
39
40 }