@@ -24,10 +24,10 @@ import org.postgresql.util.PSQLException;
24
24
* @see org.postgresql.Connection
25
25
* @see java.sql.Driver
26
26
*/
27
- public class Driver implements java.sql.Driver
27
+ public class Driver implements java.sql.Driver
28
28
{
29
-
30
- static
29
+
30
+ static
31
31
{
32
32
try {
33
33
// moved the registerDriver from the constructor to here
@@ -39,7 +39,7 @@ public class Driver implements java.sql.Driver
39
39
e.printStackTrace();
40
40
}
41
41
}
42
-
42
+
43
43
/**
44
44
* Construct a new driver and register it with DriverManager
45
45
*
@@ -54,7 +54,7 @@ public class Driver implements java.sql.Driver
54
54
//} else {
55
55
//connectClass = "postgresql.jdbc2.Connection";
56
56
//}
57
-
57
+
58
58
// Ok, when the above code was introduced in 6.5 it's intention was to allow
59
59
// the driver to automatically detect which version of JDBC was being used
60
60
// and to detect the version of the JVM accordingly.
@@ -71,7 +71,7 @@ public class Driver implements java.sql.Driver
71
71
// For this to work, the Makefile creates a pseudo class which contains the class
72
72
// name that will actually make the connection.
73
73
}
74
-
74
+
75
75
/**
76
76
* Try to make a database connection to the given URL. The driver
77
77
* should return "null" if it realizes it is the wrong kind of
@@ -85,12 +85,12 @@ public class Driver implements java.sql.Driver
85
85
*
86
86
* <p>The java.util.Properties argument can be used to pass arbitrary
87
87
* string tag/value pairs as connection arguments. Normally, at least
88
- * "user" and "password" properties should be included in the
89
- * properties. In addition, the "charSet" property can be used to
90
- * set a character set encoding (e.g. "utf-8") other than the platform
91
- * default (typically Latin1). This is necessary in particular if storing
88
+ * "user" and "password" properties should be included in the
89
+ * properties. In addition, the "charSet" property can be used to
90
+ * set a character set encoding (e.g. "utf-8") other than the platform
91
+ * default (typically Latin1). This is necessary in particular if storing
92
92
* multibyte characters in the database. For a list of supported
93
- * character encoding , see
93
+ * character encoding , see
94
94
* http://java.sun.com/products/jdk/1.2/docs/guide/internat/encoding.doc.html
95
95
* Note that you will probably want to have set up the Postgres database
96
96
* itself to use the same encoding, with the "-E <encoding>" argument
@@ -112,7 +112,7 @@ public class Driver implements java.sql.Driver
112
112
{
113
113
if((props = parseURL(url,info))==null)
114
114
return null;
115
-
115
+
116
116
try {
117
117
org.postgresql.Connection con = (org.postgresql.Connection)(Class.forName("@JDBCCONNECTCLASS@").newInstance());
118
118
con.openConnection (host(), port(), props, database(), url, this);
@@ -127,7 +127,7 @@ public class Driver implements java.sql.Driver
127
127
throw new PSQLException("postgresql.unusual",ex2);
128
128
}
129
129
}
130
-
130
+
131
131
/**
132
132
* Returns true if the driver thinks it can open a connection to the
133
133
* given URL. Typically, drivers will return true if they understand
@@ -146,7 +146,7 @@ public class Driver implements java.sql.Driver
146
146
return false;
147
147
return true;
148
148
}
149
-
149
+
150
150
/**
151
151
* The getPropertyInfo method is intended to allow a generic GUI
152
152
* tool to discover what properties it should prompt a human for
@@ -168,23 +168,23 @@ public class Driver implements java.sql.Driver
168
168
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException
169
169
{
170
170
Properties p = parseURL(url,info);
171
-
171
+
172
172
// naughty, but its best for speed. If anyone adds a property here, then
173
173
// this _MUST_ be increased to accomodate them.
174
174
DriverPropertyInfo d,dpi[] = new DriverPropertyInfo[0];
175
175
//int i=0;
176
-
176
+
177
177
//dpi[i++] = d = new DriverPropertyInfo("auth",p.getProperty("auth","default"));
178
178
//d.description = "determines if password authentication is used";
179
179
//d.choices = new String[4];
180
180
//d.choices[0]="default";// Get value from org.postgresql.auth property, defaults to trust
181
181
//d.choices[1]="trust";// No password authentication
182
182
//d.choices[2]="password";// Password authentication
183
183
//d.choices[3]="ident";// Ident (RFC 1413) protocol
184
-
184
+
185
185
return dpi;
186
186
}
187
-
187
+
188
188
/**
189
189
* Gets the drivers major version number
190
190
*
@@ -194,7 +194,7 @@ public class Driver implements java.sql.Driver
194
194
{
195
195
return @MAJORVERSION@;
196
196
}
197
-
197
+
198
198
/**
199
199
* Get the drivers minor version number
200
200
*
@@ -204,21 +204,21 @@ public class Driver implements java.sql.Driver
204
204
{
205
205
return @MINORVERSION@;
206
206
}
207
-
207
+
208
208
/**
209
209
* Returns the VERSION variable from Makefile.global
210
210
*/
211
211
public static String getVersion()
212
212
{
213
213
return "@VERSION@";
214
214
}
215
-
215
+
216
216
/**
217
217
* Report whether the driver is a genuine JDBC compliant driver. A
218
218
* driver may only report "true" here if it passes the JDBC compliance
219
219
* tests, otherwise it is required to return false. JDBC compliance
220
220
* requires full support for the JDBC API and full support for SQL 92
221
- * Entry Level.
221
+ * Entry Level.
222
222
*
223
223
* <p>For PostgreSQL, this is not yet possible, as we are not SQL92
224
224
* compliant (yet).
@@ -227,11 +227,11 @@ public class Driver implements java.sql.Driver
227
227
{
228
228
return false;
229
229
}
230
-
230
+
231
231
private Properties props;
232
-
232
+
233
233
static private String[] protocols = { "jdbc","postgresql" };
234
-
234
+
235
235
/**
236
236
* Constructs a new DriverURL, splitting the specified URL into its
237
237
* component parts
@@ -246,17 +246,17 @@ public class Driver implements java.sql.Driver
246
246
Properties urlProps = new Properties(defaults);
247
247
String key = "";
248
248
String value = "";
249
-
249
+
250
250
StringTokenizer st = new StringTokenizer(url, ":/;=&?", true);
251
251
for (int count = 0; (st.hasMoreTokens()); count++) {
252
252
String token = st.nextToken();
253
-
253
+
254
254
// PM June 29 1997
255
255
// Added this, to help me understand how this works.
256
256
// Unless you want each token to be processed, leave this commented out
257
257
// but don't delete it.
258
258
//DriverManager.println("wellFormedURL: state="+state+" count="+count+" token='"+token+"'");
259
-
259
+
260
260
// PM Aug 2 1997 - Modified to allow multiple backends
261
261
if (count <= 3) {
262
262
if ((count % 2) == 1 && token.equals(":"))
@@ -273,7 +273,7 @@ public class Driver implements java.sql.Driver
273
273
}
274
274
}
275
275
}
276
-
276
+
277
277
if(found == false)
278
278
return null;
279
279
} else return null;
@@ -322,42 +322,42 @@ public class Driver implements java.sql.Driver
322
322
}
323
323
}
324
324
}
325
-
325
+
326
326
// PM June 29 1997
327
327
// This now outputs the properties only if we are logging
328
328
// PM Sep 13 1999 Commented out, as it throws a Deprecation warning
329
329
// when compiled under JDK1.2.
330
330
//if(DriverManager.getLogStream() != null)
331
331
// urlProps.list(DriverManager.getLogStream());
332
-
332
+
333
333
return urlProps;
334
-
334
+
335
335
}
336
-
336
+
337
337
/**
338
338
* @return the hostname portion of the URL
339
339
*/
340
340
public String host()
341
341
{
342
342
return props.getProperty("PGHOST","localhost");
343
343
}
344
-
344
+
345
345
/**
346
346
* @return the port number portion of the URL or -1 if no port was specified
347
347
*/
348
348
public int port()
349
349
{
350
350
return Integer.parseInt(props.getProperty("PGPORT","5432"));
351
351
}
352
-
352
+
353
353
/**
354
354
* @return the database name of the URL
355
355
*/
356
356
public String database()
357
357
{
358
358
return props.getProperty("PGDBNAME");
359
359
}
360
-
360
+
361
361
/**
362
362
* @return the value of any property specified in the URL or properties
363
363
* passed to connect(), or null if not found.
@@ -366,7 +366,7 @@ public class Driver implements java.sql.Driver
366
366
{
367
367
return props.getProperty(name);
368
368
}
369
-
369
+
370
370
/**
371
371
* This method was added in v6.5, and simply throws an SQLException
372
372
* for an unimplemented method. I decided to do it this way while