KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mysql > jdbc > Driver


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;
20
21 /**
22  * The Java SQL framework allows for multiple database drivers. Each
23  * driver should supply a class that implements the Driver interface
24  *
25  * <p>The DriverManager will try to load as many drivers as it can find and
26  * then for any given connection request, it will ask each driver in turn
27  * to try to connect to the target URL.
28  *
29  * <p>It is strongly recommended that each Driver class should be small and
30  * standalone so that the Driver class can be loaded and queried without
31  * bringing in vast quantities of supporting code.
32  *
33  * <p>When a Driver class is loaded, it should create an instance of itself
34  * and register it with the DriverManager. This means that a user can load
35  * and register a driver by doing Class.forName("foo.bah.Driver")
36  *
37  * @see org.gjt.mm.mysql.Connection
38  * @see java.sql.Driver
39  * @author Mark Matthews
40  * @version $Id: Driver.java,v 1.20.2.6 2003/03/05 22:37:21 mmatthew Exp $
41  */

42 public class Driver extends NonRegisteringDriver {
43   
44
45     //
46
// Register ourselves with the DriverManager
47
//
48
static {
49         try {
50             java.sql.DriverManager.registerDriver(new Driver());
51         } catch (java.sql.SQLException JavaDoc E) {
52             throw new RuntimeException JavaDoc("Can't register driver!");
53         }
54
55         if (DEBUG) {
56             Debug.trace("ALL");
57         }
58     }
59
60     /**
61      * Construct a new driver and register it with DriverManager
62      *
63      * @throws java.sql.SQLException if a database error occurs.
64      */

65     public Driver() throws java.sql.SQLException JavaDoc {
66         // Required for Class.forName().newInstance()
67
}
68 }
69
Popular Tags