1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package net.wotonomy.jdbcadaptor;
19
20 import net.wotonomy.access.EOAdaptor;
21 import net.wotonomy.access.EOAdaptorContext;
22 import net.wotonomy.access.EOModel;
23 import net.wotonomy.access.EOSQLExpressionFactory;
24 import net.wotonomy.foundation.NSDictionary;
25
26
27 /***
28 * An adaptor that connects to a databaser server via JDBC.
29 *
30 * @author ezamudio@nasoft.com
31 * @author $Author: cgruber $
32 * @version $Revision: 903 $
33 */
34 public class JDBCAdaptor extends EOAdaptor {
35
36 protected EOSQLExpressionFactory _expressionFactory;
37 protected String _driverName;
38 protected NSDictionary _jdbcInfo;
39
40 /***
41 * Creates a new instance.
42 * @param name The name of the adaptor (should always be JDBC)
43 */
44 public JDBCAdaptor(String name) {
45 super(name);
46 }
47
48 public void setConnectionDictionary(NSDictionary dict) {
49 super.setConnectionDictionary(dict);
50 if (dict.objectForKey("driver") != null)
51 _driverName = (String)dict.objectForKey("driver");
52 else
53 throw new JDBCAdaptorException("Connection dictionary must have a 'driver' key.", null);
54 if (dict.objectForKey("jdbc2Info") != null)
55 _jdbcInfo = (NSDictionary)dict.objectForKey("jdbc2Info");
56 else
57 throw new JDBCAdaptorException("Connection dictionary must have a 'jdbc2Info' key.", null);
58 }
59
60
61
62
63
64 public void assertConnectionDictionaryIsValid() {
65 JDBCContext context = new JDBCContext(this);
66 context.connect();
67 context.disconnect();
68 }
69
70
71
72
73 public EOAdaptorContext createAdaptorContext() {
74 JDBCContext context = new JDBCContext(this);
75 _contexts.addObject(context);
76 return context;
77 }
78
79
80
81
82 public Class defaultExpressionClass() {
83 return JDBCExpression.class;
84 }
85
86
87
88
89 public EOSQLExpressionFactory expressionFactory() {
90 if (_expressionFactory == null)
91 _expressionFactory = new JDBCExpressionFactory(this);
92 return _expressionFactory;
93 }
94
95
96
97
98 public boolean isValidQualifierType(String typeName, EOModel model) {
99
100 return false;
101 }
102
103 public String driverName() {
104 return _driverName;
105 }
106
107 public NSDictionary jdbcInfo() {
108 return _jdbcInfo;
109 }
110
111 }
112
113
114
115
116
117
118
119
120
121
122
123