/activeobjects-plugin/src/main/java/com/atlassian/activeobjects/internal/DriverNameExtractorImpl.java
https://bitbucket.org/activeobjects/ao-plugin · Java · 31 lines · 27 code · 4 blank · 0 comment · 2 complexity · 4aac721fe6d78b8276d552ad8877f2bb MD5 · raw file
- package com.atlassian.activeobjects.internal;
- import net.java.ao.ActiveObjectsException;
- import javax.sql.DataSource;
- import java.sql.Connection;
- import java.sql.SQLException;
- public final class DriverNameExtractorImpl implements DriverNameExtractor {
- public String getDriverName(final DataSource dataSource) {
- Connection connection = null;
- try {
- connection = dataSource.getConnection();
- return connection.getMetaData().getDriverName();
- } catch (SQLException e) {
- throw new ActiveObjectsException(e);
- } finally {
- closeQuietly(connection);
- }
- }
- private static void closeQuietly(Connection connection) {
- try {
- if (connection != null) {
- connection.close();
- }
- } catch (SQLException e) {
- throw new RuntimeException(e);
- }
- }
- }