Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Connection getConnection(String name) throws SQLException {
- Connection connection=null;
- try {
- Context initContext = new InitialContext();
- DataSource ds = (DataSource) initContext.lookup(name);
- connection = ds.getConnection();
- } catch (SQLException e) {
- throw new SQLException("Connect "+name+ ", ErrorCode:" + e.getErrorCode() + ", Message:" + e.getMessage());
- } catch (NamingException e) {
- throw new SQLException("Connect "+name+ ", Message:" + e.getMessage());
- }
- return connection;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement