KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sqlmagic > tinysql > dbfFileConnection


1 /*
2  *
3  * Connection class for the dbfFile/tinySQL
4  * JDBC driver
5  *
6  * A lot of this code is based on or directly taken from
7  * George Reese's (borg@imaginary.com) mSQL driver.
8  *
9  * So, it's probably safe to say:
10  *
11  * Portions of this code Copyright (c) 1996 George Reese
12  *
13  * The rest of it:
14  *
15  * Copyright 1996 John Wiley & Sons, Inc.
16  * See the COPYING file for redistribution details.
17  *
18  * $Author: davis $
19  * $Date: 2004/12/18 21:30:05 $
20  * $Revision: 1.1 $
21  */

22 package com.sqlmagic.tinysql;
23
24
25 import java.sql.CallableStatement JavaDoc;
26 import java.sql.DatabaseMetaData JavaDoc;
27 import java.sql.Driver JavaDoc;
28 import java.sql.PreparedStatement JavaDoc;
29 import java.sql.SQLException JavaDoc;
30 import java.sql.SQLWarning JavaDoc;
31 import java.sql.Statement JavaDoc;
32
33
34 /**
35 dBase read/write access <br>
36 @author Brian Jepson <bjepson@home.com>
37 @author Marcel Ruff <ruff@swand.lake.de> Added write access to dBase and JDK 2 support
38 */

39 public class dbfFileConnection extends tinySQLConnection {
40
41   private dbfFileDatabaseMetaData myMetaData = null;
42
43   /**
44    *
45    * Constructs a new JDBC Connection object.
46    *
47    * @exception SQLException in case of an error
48    * @param user the user name - not currently used
49    * @param u the url to the data source
50    * @param d the Driver object
51    *
52    */

53   public dbfFileConnection(String JavaDoc user, String JavaDoc u, Driver JavaDoc d)
54          throws SQLException JavaDoc {
55     super(user, u, d);
56   }
57
58   /**
59    *
60    * Returns a new dbfFile object which is cast to a tinySQL
61    * object.
62    *
63    */

64   public tinySQL get_tinySQL() {
65
66      // if there's a data directory, it will
67
// be everything after the jdbc:dbfFile:
68
//
69
if (url.length() > 13) {
70        String JavaDoc dataDir = url.substring(13);
71        return (tinySQL) new dbfFile(dataDir);
72      }
73
74      // if there was no data directory specified in the
75
// url, then just use the default constructor
76
//
77
return (tinySQL) new dbfFile();
78
79   }
80
81    /**
82     * This method retrieves DatabaseMetaData
83     * @see java.sql.Connection#getMetData
84     * @exception SQLException
85     * @return a DatabaseMetaData object (conforming to JDK 2)
86     *
87     */

88    public DatabaseMetaData JavaDoc getMetaData() throws SQLException JavaDoc {
89      if (myMetaData == null)
90        myMetaData = new dbfFileDatabaseMetaData(this);
91      return (DatabaseMetaData JavaDoc)myMetaData;
92    }
93 }
94
Popular Tags