01: /*
02: * DesignTimeDBConnectionProvider.java
03: *
04: * Created on June 21, 2006, 1:05 PM
05: *
06: * To change this template, choose Tools | Template Manager
07: * and open the template in the editor.
08: */
09:
10: package org.netbeans.modules.sql.framework.common.jdbc;
11:
12: import java.sql.Connection;
13: import java.sql.SQLException;
14: import java.util.Properties;
15:
16: import org.netbeans.modules.sql.framework.common.utils.DBExplorerUtil;
17:
18: import com.sun.sql.framework.exception.BaseException;
19: import com.sun.sql.framework.jdbc.DBConnectionFactory;
20: import com.sun.sql.framework.jdbc.DBConnectionParameters;
21: import com.sun.etl.engine.spi.DBConnectionProvider;
22:
23: /**
24: *
25: * @author radval
26: */
27: public class DesignTimeDBConnectionProvider implements
28: DBConnectionProvider {
29:
30: /** Creates a new instance of DesignTimeDBConnectionProvider */
31: public DesignTimeDBConnectionProvider() {
32: }
33:
34: public Connection getConnection(DBConnectionParameters conDef)
35: throws BaseException {
36: String driver = conDef.getDriverClass();
37: String username = conDef.getUserName();
38: String password = conDef.getPassword();
39: String url = conDef.getConnectionURL();
40: return DBExplorerUtil.createConnection(driver, url, username,
41: password);
42: }
43:
44: public Connection getConnection(Properties connProps)
45: throws BaseException {
46: String driver = connProps
47: .getProperty(DBConnectionFactory.PROP_DRIVERCLASS);
48: String username = connProps
49: .getProperty(DBConnectionFactory.PROP_USERNAME);
50: String password = connProps
51: .getProperty(DBConnectionFactory.PROP_PASSWORD);
52: String url = connProps
53: .getProperty(DBConnectionFactory.PROP_URL);
54: return DBExplorerUtil.createConnection(driver, url, username,
55: password);
56: }
57:
58: public void closeConnection(Connection con) {
59: try {
60: if (con != null) {
61: con.close();
62: }
63: } catch (SQLException ex) {
64: //ignore
65: } finally {
66: if (con != null) {
67: try {
68: con.close();
69: } catch (SQLException e) {
70: //ignore
71: }
72: }
73: }
74: }
75: }
|