1 /*
2 Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of version 2 of the GNU General Public License as
6 published by the Free Software Foundation.
7
8 There are special exceptions to the terms and conditions of the GPL
9 as it is applied to this software. View the full text of the
10 exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
11 software distribution.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22
23
24 */
25 package com.mysql.jdbc;
26
27 import java.sql.SQLException;
28
29 /**
30 * The Java SQL framework allows for multiple database drivers. Each driver
31 * should supply a class that implements the Driver interface
32 *
33 * <p>
34 * The DriverManager will try to load as many drivers as it can find and then
35 * for any given connection request, it will ask each driver in turn to try to
36 * connect to the target URL.
37 *
38 * <p>
39 * It is strongly recommended that each Driver class should be small and
40 * standalone so that the Driver class can be loaded and queried without
41 * bringing in vast quantities of supporting code.
42 *
43 * <p>
44 * When a Driver class is loaded, it should create an instance of itself and
45 * register it with the DriverManager. This means that a user can load and
46 * register a driver by doing Class.forName("foo.bah.Driver")
47 *
48 * @see org.gjt.mm.mysql.Connection
49 * @see java.sql.Driver
50 * @author Mark Matthews
51 * @version $Id$
52 */
53 public class Driver extends NonRegisteringDriver implements java.sql.Driver {
54 // ~ Static fields/initializers
55 // ---------------------------------------------
56
57 //
58 // Register ourselves with the DriverManager
59 //
60 static {
61 try {
62 java.sql.DriverManager.registerDriver(new Driver());
63 } catch (SQLException E) {
64 throw new RuntimeException("Can't register driver!");
65 }
66 }
67
68 // ~ Constructors
69 // -----------------------------------------------------------
70
71 /**
72 * Construct a new driver and register it with DriverManager
73 *
74 * @throws SQLException
75 * if a database error occurs.
76 */
77 public Driver() throws SQLException {
78 // Required for Class.forName().newInstance()
79 }
80 }