~mark-matthews-a/connectorj/trunk

« back to all changes in this revision

Viewing changes to src/com/mysql/jdbc/NonRegisteringDriver.java

  • Committer: mark.matthews at oracle
  • Date: 2010-05-12 15:38:46 UTC
  • mfrom: (847.1.94 branch_5_1-local)
  • Revision ID: mark.matthews@oracle.com-20100512153846-bdyw3aezw5o1szmu
MergedĀ fromĀ 5.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
281
281
                        return null;
282
282
                }
283
283
 
 
284
                if (!"1".equals(props.getProperty(NUM_HOSTS_PROPERTY_KEY))) {
 
285
                        return connectFailover(url, info);
 
286
                }
 
287
                
284
288
                try {
285
289
                        Connection newConn = com.mysql.jdbc.ConnectionImpl.getInstance(
286
290
                                        host(props), port(props), props, database(props), url);
316
320
 
317
321
                int numHosts = Integer.parseInt(parsedProps.getProperty(NUM_HOSTS_PROPERTY_KEY));
318
322
 
319
 
                List hostList = new ArrayList();
 
323
                List<String> hostList = new ArrayList<String>();
320
324
 
321
325
                for (int i = 0; i < numHosts; i++) {
322
326
                        int index = i + 1;
332
336
                                .getClass().getClassLoader(),
333
337
                                new Class[] { com.mysql.jdbc.Connection.class }, proxyBal);
334
338
        }
 
339
        
 
340
        private java.sql.Connection connectFailover(String url, Properties info)
 
341
                        throws SQLException {
 
342
                Properties parsedProps = parseURL(url, info);
 
343
 
 
344
                // People tend to drop this in, it doesn't make sense
 
345
                parsedProps.remove("roundRobinLoadBalance");
 
346
                parsedProps.setProperty("autoReconnect", "false");
 
347
                
 
348
                if (parsedProps == null) {
 
349
                        return null;
 
350
                }
 
351
 
 
352
                int numHosts = Integer.parseInt(parsedProps
 
353
                                .getProperty(NUM_HOSTS_PROPERTY_KEY));
 
354
 
 
355
                List<String> hostList = new ArrayList<String>();
 
356
                
 
357
                for (int i = 0; i < numHosts; i++) {
 
358
                        int index = i + 1;
 
359
 
 
360
                        hostList.add(parsedProps.getProperty(HOST_PROPERTY_KEY + "."
 
361
                                        + index)
 
362
                                        + ":"
 
363
                                        + parsedProps.getProperty(PORT_PROPERTY_KEY + "." + index));
 
364
                }
 
365
 
 
366
                FailoverConnectionProxy connProxy = new FailoverConnectionProxy(
 
367
                                hostList, parsedProps);
 
368
 
 
369
                return (java.sql.Connection) java.lang.reflect.Proxy.newProxyInstance(
 
370
                                this.getClass().getClassLoader(),
 
371
                                new Class[] { com.mysql.jdbc.Connection.class }, connProxy);
 
372
        }
335
373
 
336
374
        protected java.sql.Connection connectReplicationConnection(String url, Properties info)
337
375
                        throws SQLException {