KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mysql > jdbc > jdbc2 > optional > ConnectionWrapper


1 /*
2    Copyright (C) 2002 MySQL AB
3
4       This program is free software; you can redistribute it and/or modify
5       it under the terms of the GNU General Public License as published by
6       the Free Software Foundation; either version 2 of the License, or
7       (at your option) any later version.
8
9       This program is distributed in the hope that it will be useful,
10       but WITHOUT ANY WARRANTY; without even the implied warranty of
11       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12       GNU General Public License for more details.
13
14       You should have received a copy of the GNU General Public License
15       along with this program; if not, write to the Free Software
16       Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18  */

19 package com.mysql.jdbc.jdbc2.optional;
20
21 import java.sql.Connection JavaDoc;
22 import java.sql.ResultSet JavaDoc;
23 import java.sql.SQLException JavaDoc;
24 import java.sql.Savepoint JavaDoc;
25 import java.sql.Statement JavaDoc;
26
27
28 /**
29  * This class serves as a wrapper for the org.gjt.mm.mysql.jdbc2.Connection
30  * class. It is returned to the application server which may wrap it again
31  * and then return it to the application client in response to
32  * dataSource.getConnection().
33  *
34  * <p>
35  * All method invocations are forwarded to org.gjt.mm.mysql.jdbc2.Connection
36  * unless the close method was previously called, in which case a sqlException
37  * is thrown. The close method performs a 'logical close' on the connection.
38  * </p>
39  *
40  * <p>
41  * All sqlExceptions thrown by the physical connection are intercepted and sent
42  * to connectionEvent listeners before being thrown to client.
43  * </p>
44  *
45  * @author Todd Wolff todd.wolff_at_prodigy.net
46  *
47  * @see org.gjt.mm.mysql.jdbc2.Connection
48  * @see org.gjt.mm.mysql.jdbc2.optional.MysqlPooledConnection
49  */

50 class ConnectionWrapper extends WrapperBase implements Connection JavaDoc {
51     private Connection JavaDoc mc = null;
52     private MysqlPooledConnection mpc = null;
53     private String JavaDoc invalidHandleStr = "Logical handle no longer valid";
54     private boolean closed;
55
56     /**
57      * Construct a new LogicalHandle and set instance variables
58      *
59      * @param mysqlPooledConnection reference to object that instantiated this
60      * object
61      * @param mysqlConnection physical connection to db
62      *
63      * @throws SQLException if an error occurs.
64      */

65     public ConnectionWrapper(MysqlPooledConnection mysqlPooledConnection,
66         Connection JavaDoc mysqlConnection) throws SQLException JavaDoc {
67         this.mpc = mysqlPooledConnection;
68         this.mc = mysqlConnection;
69         this.closed = false;
70         this.pooledConnection = this.mpc;
71     }
72
73     /**
74      * Passes call to method on physical connection instance. Notifies
75      * listeners of any caught exceptions before re-throwing to client.
76      *
77      * @see java.sql.Connection#setAutoCommit
78      */

79     public void setAutoCommit(boolean autoCommit) throws SQLException JavaDoc {
80         if (closed) {
81             throw new SQLException JavaDoc(invalidHandleStr);
82         } else {
83             try {
84                 mc.setAutoCommit(autoCommit);
85             } catch (SQLException JavaDoc sqlException) {
86                 checkAndFireConnectionError(sqlException);
87             }
88         }
89     }
90
91     /**
92      * Passes call to method on physical connection instance. Notifies
93      * listeners of any caught exceptions before re-throwing to client.
94      *
95      * @see java.sql.Connection#getAutoCommit()
96      */

97     public boolean getAutoCommit() throws SQLException JavaDoc {
98         if (closed) {
99             throw new SQLException JavaDoc(invalidHandleStr);
100         } else {
101             try {
102                 return mc.getAutoCommit();
103             } catch (SQLException JavaDoc sqlException) {
104                 checkAndFireConnectionError(sqlException);
105             }
106         }
107         
108         return false; // we don't reach this code, compiler can't tell
109
}
110
111     /**
112      * Passes call to method on physical connection instance. Notifies
113      * listeners of any caught exceptions before re-throwing to client.
114      *
115      * @see java.sql.Connection#setCatalog()
116      */

117     public void setCatalog(String JavaDoc catalog) throws SQLException JavaDoc {
118         if (closed) {
119             throw new SQLException JavaDoc(invalidHandleStr);
120         } else {
121             try {
122                 mc.setCatalog(catalog);
123             } catch (SQLException JavaDoc sqlException) {
124                 checkAndFireConnectionError(sqlException);
125             }
126         }
127     }
128
129     /**
130      * Passes call to method on physical connection instance. Notifies
131      * listeners of any caught exceptions before re-throwing to client.
132      *
133      * @return the current catalog
134      *
135      * @throws SQLException if an error occurs
136      */

137     public String JavaDoc getCatalog() throws SQLException JavaDoc {
138         if (closed) {
139             throw new SQLException JavaDoc(invalidHandleStr);
140         } else {
141             try {
142                 return mc.getCatalog();
143             } catch (SQLException JavaDoc sqlException) {
144                 checkAndFireConnectionError(sqlException);
145             }
146         }
147         
148         return null; // we don't reach this code, compiler can't tell
149
}
150
151     /**
152      * Passes call to method on physical connection instance. Notifies
153      * listeners of any caught exceptions before re-throwing to client.
154      *
155      * @see java.sql.Connection#isClosed()
156      */

157     public boolean isClosed() throws SQLException JavaDoc {
158         return (closed || mc.isClosed());
159     }
160
161     /**
162      * @see Connection#setHoldability(int)
163      */

164     public void setHoldability(int arg0) throws SQLException JavaDoc {
165         if (closed) {
166             throw new SQLException JavaDoc(invalidHandleStr);
167         } else {
168             try {
169                 mc.setHoldability(arg0);
170             } catch (SQLException JavaDoc sqlException) {
171                 checkAndFireConnectionError(sqlException);
172             }
173         }
174     }
175
176     /**
177      * @see Connection#getHoldability()
178      */

179     public int getHoldability() throws SQLException JavaDoc {
180         if (closed) {
181             throw new SQLException JavaDoc(invalidHandleStr);
182         } else {
183             try {
184                 return mc.getHoldability();
185             } catch (SQLException JavaDoc sqlException) {
186                 checkAndFireConnectionError(sqlException);
187             }
188         }
189         
190         return Statement.CLOSE_CURRENT_RESULT; // we don't reach this code, compiler can't tell
191
}
192
193     /**
194      * Allows clients to determine how long this connection has been idle.
195      *
196      * @return how long the connection has been idle.
197      */

198     public long getIdleFor() {
199         return ((com.mysql.jdbc.Connection) mc).getIdleFor();
200     }
201
202     /**
203      * Passes call to method on physical connection instance. Notifies
204      * listeners of any caught exceptions before re-throwing to client.
205      *
206      * @return a metadata instance
207      *
208      * @throws SQLException if an error occurs
209      */

210     public java.sql.DatabaseMetaData JavaDoc getMetaData() throws SQLException JavaDoc {
211         if (closed) {
212             throw new SQLException JavaDoc(invalidHandleStr);
213         } else {
214             try {
215                 return mc.getMetaData();
216             } catch (SQLException JavaDoc sqlException) {
217                 checkAndFireConnectionError(sqlException);
218             }
219         }
220         
221         return null; // we don't reach this code, compiler can't tell
222
}
223
224     /**
225      * Passes call to method on physical connection instance. Notifies
226      * listeners of any caught exceptions before re-throwing to client.
227      *
228      * @see java.sql.Connection#setReadOnly()
229      */

230     public void setReadOnly(boolean readOnly) throws SQLException JavaDoc {
231         if (closed) {
232             throw new SQLException JavaDoc(invalidHandleStr);
233         } else {
234             try {
235                 mc.setReadOnly(readOnly);
236             } catch (SQLException JavaDoc sqlException) {
237                 checkAndFireConnectionError(sqlException);
238             }
239         }
240     }
241
242     /**
243      * Passes call to method on physical connection instance. Notifies
244      * listeners of any caught exceptions before re-throwing to client.
245      *
246      * @see java.sql.Connection#isReadOnly()
247      */

248     public boolean isReadOnly() throws SQLException JavaDoc {
249         if (closed) {
250             throw new SQLException JavaDoc(invalidHandleStr);
251         } else {
252             try {
253                 return mc.isReadOnly();
254             } catch (SQLException JavaDoc sqlException) {
255                 checkAndFireConnectionError(sqlException);
256             }
257         }
258         
259         return false; // we don't reach this code, compiler can't tell
260
}
261
262     /**
263      * @see Connection#setSavepoint()
264      */

265     public java.sql.Savepoint JavaDoc setSavepoint() throws SQLException JavaDoc {
266         if (closed) {
267             throw new SQLException JavaDoc(invalidHandleStr);
268         } else {
269             try {
270                 return mc.setSavepoint();
271             } catch (SQLException JavaDoc sqlException) {
272                 checkAndFireConnectionError(sqlException);
273             }
274         }
275         
276         return null; // we don't reach this code, compiler can't tell
277
}
278
279     /**
280      * @see Connection#setSavepoint(String)
281      */

282     public java.sql.Savepoint JavaDoc setSavepoint(String JavaDoc arg0)
283         throws SQLException JavaDoc {
284         if (closed) {
285             throw new SQLException JavaDoc(invalidHandleStr);
286         } else {
287             try {
288                 return mc.setSavepoint(arg0);
289             } catch (SQLException JavaDoc sqlException) {
290                 checkAndFireConnectionError(sqlException);
291             }
292         }
293         
294         return null; // we don't reach this code, compiler can't tell
295
}
296
297     /**
298      * Passes call to method on physical connection instance. Notifies
299      * listeners of any caught exceptions before re-throwing to client.
300      *
301      * @see java.sql.Connection#setTransactionIsolation()
302      */

303     public void setTransactionIsolation(int level) throws SQLException JavaDoc {
304         if (closed) {
305             throw new SQLException JavaDoc(invalidHandleStr);
306         } else {
307             try {
308                 mc.setTransactionIsolation(level);
309             } catch (SQLException JavaDoc sqlException) {
310                 checkAndFireConnectionError(sqlException);
311             }
312         }
313     }
314
315     /**
316      * Passes call to method on physical connection instance. Notifies
317      * listeners of any caught exceptions before re-throwing to client.
318      *
319      * @see java.sql.Connection#getTransactionIsolation()
320      */

321     public int getTransactionIsolation() throws SQLException JavaDoc {
322         if (closed) {
323             throw new SQLException JavaDoc(invalidHandleStr);
324         } else {
325             try {
326                 return mc.getTransactionIsolation();
327             } catch (SQLException JavaDoc sqlException) {
328                 checkAndFireConnectionError(sqlException);
329             }
330         }
331         
332         return TRANSACTION_REPEATABLE_READ; // we don't reach this code, compiler can't tell
333
}
334
335     /**
336      * Passes call to method on physical connection instance. Notifies
337      * listeners of any caught exceptions before re-throwing to client.
338      *
339      * @see java.sql.Connection#setTypeMap()
340      */

341     public void setTypeMap(java.util.Map JavaDoc map) throws SQLException JavaDoc {
342         if (closed) {
343             throw new SQLException JavaDoc(invalidHandleStr);
344         } else {
345             try {
346                 mc.setTypeMap(map);
347             } catch (SQLException JavaDoc sqlException) {
348                 checkAndFireConnectionError(sqlException);
349             }
350         }
351     }
352
353     /**
354      * Passes call to method on physical connection instance. Notifies
355      * listeners of any caught exceptions before re-throwing to client.
356      *
357      * @see java.sql.Connection#getTypeMap()
358      */

359     public java.util.Map JavaDoc getTypeMap() throws SQLException JavaDoc {
360         if (closed) {
361             throw new SQLException JavaDoc(invalidHandleStr);
362         } else {
363             try {
364                 return mc.getTypeMap();
365             } catch (SQLException JavaDoc sqlException) {
366                 checkAndFireConnectionError(sqlException);
367             }
368         }
369         
370         return null; // we don't reach this code, compiler can't tell
371
}
372
373     /**
374      * Passes call to method on physical connection instance. Notifies
375      * listeners of any caught exceptions before re-throwing to client.
376      *
377      * @see java.sql.Connection#getWarnings
378      */

379     public java.sql.SQLWarning JavaDoc getWarnings() throws SQLException JavaDoc {
380         if (closed) {
381             throw new SQLException JavaDoc(invalidHandleStr);
382         } else {
383             try {
384                 return mc.getWarnings();
385             } catch (SQLException JavaDoc sqlException) {
386                 checkAndFireConnectionError(sqlException);
387             }
388         }
389         
390         return null; // we don't reach this code, compiler can't tell
391
}
392
393     /**
394      * Passes call to method on physical connection instance. Notifies
395      * listeners of any caught exceptions before re-throwing to client.
396      *
397      * @throws SQLException if an error occurs
398      */

399     public void clearWarnings() throws SQLException JavaDoc {
400         if (closed) {
401             throw new SQLException JavaDoc(invalidHandleStr);
402         } else {
403             try {
404                 mc.clearWarnings();
405             } catch (SQLException JavaDoc sqlException) {
406                 checkAndFireConnectionError(sqlException);
407             }
408         }
409     }
410
411     /**
412      * The physical connection is not actually closed. the physical connection
413      * is closed when the application server calls
414      * mysqlPooledConnection.close(). this object is de-referenced by the
415      * pooled connection each time mysqlPooledConnection.getConnection() is
416      * called by app server.
417      *
418      * @throws SQLException if an error occurs
419      */

420     public void close() throws SQLException JavaDoc {
421         close(true);
422     }
423
424     /**
425      * Passes call to method on physical connection instance. Notifies
426      * listeners of any caught exceptions before re-throwing to client.
427      *
428      * @throws SQLException if an error occurs
429      */

430     public void commit() throws SQLException JavaDoc {
431         if (closed) {
432             throw new SQLException JavaDoc(invalidHandleStr);
433         } else {
434             try {
435                 mc.commit();
436             } catch (SQLException JavaDoc sqlException) {
437                 checkAndFireConnectionError(sqlException);
438             }
439         }
440     }
441
442     /**
443      * Passes call to method on physical connection instance. Notifies
444      * listeners of any caught exceptions before re-throwing to client.
445      *
446      * @see java.sql.Connection#createStatement()
447      */

448     public java.sql.Statement JavaDoc createStatement() throws SQLException JavaDoc {
449         if (this.closed) {
450             throw new SQLException JavaDoc(invalidHandleStr);
451         } else {
452             try {
453                 return new StatementWrapper(this.mpc, mc.createStatement());
454             } catch (SQLException JavaDoc sqlException) {
455                 checkAndFireConnectionError(sqlException);
456             }
457         }
458         
459         return null; // we don't reach this code, compiler can't tell
460
}
461
462     /**
463      * Passes call to method on physical connection instance. Notifies
464      * listeners of any caught exceptions before re-throwing to client.
465      *
466      * @see java.sql.Connection#createStatement()
467      */

468     public java.sql.Statement JavaDoc createStatement(int resultSetType,
469         int resultSetConcurrency) throws SQLException JavaDoc {
470         if (this.closed) {
471             throw new SQLException JavaDoc(invalidHandleStr);
472         } else {
473             try {
474                 return new StatementWrapper(this.mpc, mc.createStatement(resultSetType, resultSetConcurrency));
475             } catch (SQLException JavaDoc sqlException) {
476                 checkAndFireConnectionError(sqlException);
477             }
478         }
479         
480         return null; // we don't reach this code, compiler can't tell
481
}
482
483     /**
484      * @see Connection#createStatement(int, int, int)
485      */

486     public java.sql.Statement JavaDoc createStatement(int arg0, int arg1, int arg2)
487         throws SQLException JavaDoc {
488         if (this.closed) {
489             throw new SQLException JavaDoc(invalidHandleStr);
490         } else {
491             try {
492                 return new StatementWrapper(this.mpc, mc.createStatement(arg0, arg1, arg2));
493             } catch (SQLException JavaDoc sqlException) {
494                 checkAndFireConnectionError(sqlException);
495             }
496         }
497         
498         return null; // we don't reach this code, compiler can't tell
499
}
500
501     /**
502      * Passes call to method on physical connection instance. Notifies
503      * listeners of any caught exceptions before re-throwing to client.
504      *
505      * @see java.sql.Connection#nativeSQL()
506      */

507     public String JavaDoc nativeSQL(String JavaDoc sql) throws SQLException JavaDoc {
508         if (closed) {
509             throw new SQLException JavaDoc(invalidHandleStr);
510         } else {
511             try {
512                 return mc.nativeSQL(sql);
513             } catch (SQLException JavaDoc sqlException) {
514                 checkAndFireConnectionError(sqlException);
515             }
516         }
517         
518         return null; // we don't reach this code, compiler can't tell
519
}
520
521     /**
522      * Passes call to method on physical connection instance. Notifies
523      * listeners of any caught exceptions before re-throwing to client.
524      *
525      * @see java.sql.Connection#prepareCall()
526      */

527     public java.sql.CallableStatement JavaDoc prepareCall(String JavaDoc sql)
528         throws SQLException JavaDoc {
529         if (closed) {
530             throw new SQLException JavaDoc(invalidHandleStr);
531         } else {
532             try {
533                 return mc.prepareCall(sql);
534             } catch (SQLException JavaDoc sqlException) {
535                 checkAndFireConnectionError(sqlException);
536             }
537         }
538         
539         return null; // we don't reach this code, compiler can't tell
540
}
541
542     /**
543      * Passes call to method on physical connection instance. Notifies
544      * listeners of any caught exceptions before re-throwing to client.
545      *
546      * @see java.sql.Connection#prepareCall()
547      */

548     public java.sql.CallableStatement JavaDoc prepareCall(String JavaDoc sql,
549         int resultSetType, int resultSetConcurrency) throws SQLException JavaDoc {
550         if (closed) {
551             throw new SQLException JavaDoc(invalidHandleStr);
552         } else {
553             try {
554                 return mc.prepareCall(sql, resultSetType, resultSetConcurrency);
555             } catch (SQLException JavaDoc sqlException) {
556                 checkAndFireConnectionError(sqlException);
557             }
558         }
559         
560         return null; // we don't reach this code, compiler can't tell
561
}
562
563     /**
564      * @see Connection#prepareCall(String, int, int, int)
565      */

566     public java.sql.CallableStatement JavaDoc prepareCall(String JavaDoc arg0, int arg1,
567         int arg2, int arg3) throws SQLException JavaDoc {
568         if (closed) {
569             throw new SQLException JavaDoc(invalidHandleStr);
570         } else {
571             try {
572                 return mc.prepareCall(arg0, arg1, arg2, arg3);
573             } catch (SQLException JavaDoc sqlException) {
574                 checkAndFireConnectionError(sqlException);
575             }
576         }
577         
578         return null; // we don't reach this code, compiler can't tell
579
}
580
581     /**
582      * Passes call to method on physical connection instance. Notifies
583      * listeners of any caught exceptions before re-throwing to client.
584      *
585      * @see java.sql.Connection#prepareStatement()
586      */

587     public java.sql.PreparedStatement JavaDoc prepareStatement(String JavaDoc sql)
588         throws SQLException JavaDoc {
589         if (this.closed) {
590             throw new SQLException JavaDoc(invalidHandleStr);
591         } else {
592             try {
593                 return new PreparedStatementWrapper(this.mpc, mc.prepareStatement(sql));
594             } catch (SQLException JavaDoc sqlException) {
595                 checkAndFireConnectionError(sqlException);
596             }
597         }
598         
599         return null; // we don't reach this code, compiler can't tell
600
}
601
602     /**
603      * Passes call to method on physical connection instance. Notifies
604      * listeners of any caught exceptions before re-throwing to client.
605      *
606      * @see java.sql.Connection#prepareStatement()
607      */

608     public java.sql.PreparedStatement JavaDoc prepareStatement(String JavaDoc sql,
609         int resultSetType, int resultSetConcurrency) throws SQLException JavaDoc {
610         if (this.closed) {
611             throw new SQLException JavaDoc(invalidHandleStr);
612         } else {
613             try {
614                 return new PreparedStatementWrapper(this.mpc, mc.prepareStatement(sql, resultSetType,
615                     resultSetConcurrency));
616             } catch (SQLException JavaDoc sqlException) {
617                 checkAndFireConnectionError(sqlException);
618             }
619         }
620         
621         return null; // we don't reach this code, compiler can't tell
622
}
623
624     /**
625      * @see Connection#prepareStatement(String, int, int, int)
626      */

627     public java.sql.PreparedStatement JavaDoc prepareStatement(String JavaDoc arg0, int arg1,
628         int arg2, int arg3) throws SQLException JavaDoc {
629         if (this.closed) {
630             throw new SQLException JavaDoc(invalidHandleStr);
631         } else {
632             try {
633                 return new PreparedStatementWrapper(this.mpc, mc.prepareStatement(arg0, arg1, arg2, arg3));
634             } catch (SQLException JavaDoc sqlException) {
635                 checkAndFireConnectionError(sqlException);
636             }
637         }
638         
639         return null; // we don't reach this code, compiler can't tell
640
}
641
642     /**
643      * @see Connection#prepareStatement(String, int)
644      */

645     public java.sql.PreparedStatement JavaDoc prepareStatement(String JavaDoc arg0, int arg1)
646         throws SQLException JavaDoc {
647         if (this.closed) {
648             throw new SQLException JavaDoc(invalidHandleStr);
649         } else {
650             try {
651                 return new PreparedStatementWrapper(this.mpc, mc.prepareStatement(arg0, arg1));
652             } catch (SQLException JavaDoc sqlException) {
653                 checkAndFireConnectionError(sqlException);
654             }
655         }
656         
657         return null; // we don't reach this code, compiler can't tell
658
}
659
660     /**
661      * @see Connection#prepareStatement(String, int[])
662      */

663     public java.sql.PreparedStatement JavaDoc prepareStatement(String JavaDoc arg0, int[] arg1)
664         throws SQLException JavaDoc {
665         if (this.closed) {
666             throw new SQLException JavaDoc(invalidHandleStr);
667         } else {
668             try {
669                 return new PreparedStatementWrapper(this.mpc, mc.prepareStatement(arg0, arg1));
670             } catch (SQLException JavaDoc sqlException) {
671                 checkAndFireConnectionError(sqlException);
672             }
673         }
674         
675         return null; // we don't reach this code, compiler can't tell
676
}
677
678     /**
679      * @see Connection#prepareStatement(String, String[])
680      */

681     public java.sql.PreparedStatement JavaDoc prepareStatement(String JavaDoc arg0,
682         String JavaDoc[] arg1) throws SQLException JavaDoc {
683         if (this.closed) {
684             throw new SQLException JavaDoc(invalidHandleStr);
685         } else {
686             try {
687                 return new PreparedStatementWrapper(this.mpc, mc.prepareStatement(arg0, arg1));
688             } catch (SQLException JavaDoc sqlException) {
689                 checkAndFireConnectionError(sqlException);
690             }
691         }
692         
693         return null; // we don't reach this code, compiler can't tell
694
}
695
696     /**
697      * @see Connection#releaseSavepoint(Savepoint)
698      */

699     public void releaseSavepoint(Savepoint JavaDoc arg0) throws SQLException JavaDoc {
700         if (closed) {
701             throw new SQLException JavaDoc(invalidHandleStr);
702         } else {
703             try {
704                 mc.releaseSavepoint(arg0);
705             } catch (SQLException JavaDoc sqlException) {
706                 checkAndFireConnectionError(sqlException);
707             }
708         }
709     }
710
711     /**
712      * Passes call to method on physical connection instance. Notifies
713      * listeners of any caught exceptions before re-throwing to client.
714      *
715      * @see java.sql.Connection#rollback()
716      */

717     public void rollback() throws SQLException JavaDoc {
718         if (closed) {
719             throw new SQLException JavaDoc(invalidHandleStr);
720         } else {
721             try {
722                 mc.rollback();
723             } catch (SQLException JavaDoc sqlException) {
724                 checkAndFireConnectionError(sqlException);
725             }
726         }
727     }
728
729     /**
730      * @see Connection#rollback(Savepoint)
731      */

732     public void rollback(Savepoint JavaDoc arg0) throws SQLException JavaDoc {
733         if (closed) {
734             throw new SQLException JavaDoc(invalidHandleStr);
735         } else {
736             try {
737                 mc.rollback(arg0);
738             } catch (SQLException JavaDoc sqlException) {
739                 checkAndFireConnectionError(sqlException);
740             }
741         }
742     }
743
744     protected void close(boolean fireClosedEvent)
745         throws SQLException JavaDoc {
746         
747         synchronized (this.mpc) {
748             if (closed) {
749                 return;
750             }
751
752             if (fireClosedEvent) {
753                 mpc.callListener(MysqlPooledConnection.CONNECTION_CLOSED_EVENT, null);
754             }
755
756             // set closed status to true so that if application client tries to make additional
757
// calls a sqlException will be thrown. The physical connection is
758
// re-used by the pooled connection each time getConnection is called.
759
this.closed = true;
760         }
761     }
762 }
763
Popular Tags