BUG 2799: SPI for EventSources
[controller.git] / opendaylight / md-sal / sal-dom-xsql / src / main / java / org / odl / xsql / JDBCDriver.java
1 package org.odl.xsql;
2
3 import java.sql.Connection;
4 import java.sql.Driver;
5 import java.sql.DriverManager;
6 import java.sql.DriverPropertyInfo;
7 import java.sql.SQLException;
8 import java.sql.SQLFeatureNotSupportedException;
9 import java.util.Properties;
10 import java.util.logging.Logger;
11
12 import org.opendaylight.controller.md.sal.dom.xsql.jdbc.JDBCConnection;
13
14 public class JDBCDriver implements Driver {
15
16     public static JDBCDriver drv = new JDBCDriver();
17
18     public JDBCDriver() {
19         try {
20             DriverManager.registerDriver(this);
21         } catch (SQLException e) {
22             // TODO Auto-generated catch block
23             e.printStackTrace();
24         }
25     }
26
27     @Override
28     public boolean acceptsURL(String arg0) throws SQLException {
29         return true;
30     }
31
32     @Override
33     public Connection connect(String url, Properties arg1) throws SQLException {
34         System.err.println("JDBC Connection");
35         try {
36             if (url.equals("svr")) {
37                 return new JDBCConnection(true);
38             } else {
39                 return new JDBCConnection(url).getProxy();
40             }
41         } catch (Exception err) {
42             err.printStackTrace();
43         }
44         System.err.println("Error JDBC Connection");
45         return null;
46     }
47
48     @Override
49     public int getMajorVersion() {
50         return 1;
51     }
52
53     @Override
54     public int getMinorVersion() {
55         return 0;
56     }
57
58     @Override
59     public DriverPropertyInfo[] getPropertyInfo(String arg0, Properties arg1)
60         throws SQLException {
61         DriverPropertyInfo i = new DriverPropertyInfo("OpenDayLight", "OpenDayLight");
62         return new DriverPropertyInfo[] {i};
63     }
64
65     @Override
66     public boolean jdbcCompliant() {
67         return false;
68     }
69
70     @Override
71     public Logger getParentLogger() throws SQLFeatureNotSupportedException {
72         // TODO Auto-generated method stub
73         return null;
74     }
75
76 }