/Users/lyon/j4p/src/classUtils/pack/util/jdbc/JdbcOdbcURL.java
|
1 package classUtils.pack.util.jdbc;
2
3 /**
4 * An URL for the Jdbc-Odbc bridge. The <b>database</b> symbol is used for the data source.
5 * Only the <b>user</b> and <b>password</b> are supported, but arbitrary ODBC attributes
6 * can be passed at construction in a string whose format is
7 * <tt><i>attribute-name</i>=$(<i>attribute-name</i>);</tt>, for example:
8 * <p>
9 * <tt>JdbcOdbcURL url = new JdbcOdbcURL("ora123", "Cachesize=$(cachesize);")</tt>
10 * <p>
11 * creates a Jdbc/Odbc URL for an oracle data source with a <tt>Cachesize</tt> attribute,
12 * whose value can then be defined by:
13 * <p>
14 * <tt>url.setAttributeValue("cachesize", "300");</tt>
15 * <p>.
16 *
17 * @author Cristiano Sadun
18 *
19 */
20 public class JdbcOdbcURL extends JdbcURL {
21
22 /**
23 * Constructor for JdbcOdbcURL.
24 *
25 * @param database the ODBC data source name
26 * @param uid the user id for connecting
27 * @param password the password for connecting
28 * @param additionalODBCattributes a semicolon-separated
29 * of ODBC attributes in
30 * <tt><i>attribute-name</i>=$(;<i>attribute-name</i>);</tt>
31 * format, different than <tt>UID</tt> and <tt>PWD</tt>
32 */
33 public JdbcOdbcURL(String database, String uid, String pwd, String additionalODBCattributes) {
34 super("jdbc:odbc:$<database>;UID=$<user>;PWD=$<password>"+
35 (additionalODBCattributes != null ? ";"+additionalODBCattributes : "")
36 );
37 if (database!=null) setDatabase(database);
38 if (uid!=null) setUser(uid);
39 if (pwd!=null) setPassword(pwd);
40 }
41
42 /**
43 * Constructor for JdbcOdbcURL which defines no uid/password.
44 *
45 * @param database the ODBC data source name
46 * @param additionalODBCattributes a semicolon-separated
47 * of ODBC attributes in
48 * <tt><i>attribute-name</i>=$(;<i>attribute-name</i>);</tt>
49 * format, different than <tt>UID</tt> and <tt>PWD</tt>
50 */
51 public JdbcOdbcURL(String database, String additionalODBCattributes) {
52 this(database, "", "", additionalODBCattributes);
53 }
54
55 /**
56 * Constructor for JdbcOdbcURL requires post-construction definition of the
57 * data source, and which defines no uid/password.
58 *
59 * @param additionalODBCattributes a semicolon-separated
60 * of ODBC attributes in
61 * <tt><i>attribute-name</i>=$(;<i>attribute-name</i>);</tt>
62 * format, different than <tt>UID</tt> and <tt>PWD</tt>
63 */
64 public JdbcOdbcURL(String additionalODBCattributes) {
65 this(null, null, null, additionalODBCattributes);
66 }
67
68 /**
69 * Constructor for JdbcOdbcURL requires post-construction definition of the
70 * data source, and which defines no uid/password.
71 */
72 public JdbcOdbcURL() {
73 this(null, null, null, null);
74 }
75
76 /**
77 * @see classUtils.pack.util.jdbc.JdbcURL#setDatabase(String)
78 */
79 public void setDatabase(String database) {
80 super.setDatabase(database);
81 }
82
83 /**
84 * @see classUtils.pack.util.jdbc.JdbcURL#setPassword(String)
85 */
86 public void setPassword(String password) {
87 super.setPassword(password);
88 }
89
90 /**
91 * @see classUtils.pack.util.jdbc.JdbcURL#setUser(String)
92 */
93 public void setUser(String username) {
94 super.setUser(username);
95 }
96
97 /**
98 * Set one of the additional attributes passed at construction.
99 */
100 public void setAttributeValue(String attributeName, String value) {
101 super.setSymbolValue(attributeName, value);
102 }
103
104 }
105