01: /*
02: *
03: * Connection class for the dbfFile/tinySQL
04: * JDBC driver
05: *
06: * A lot of this code is based on or directly taken from
07: * George Reese's (borg@imaginary.com) mSQL driver.
08: *
09: * 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: import java.sql.CallableStatement;
25: import java.sql.DatabaseMetaData;
26: import java.sql.Driver;
27: import java.sql.PreparedStatement;
28: import java.sql.SQLException;
29: import java.sql.SQLWarning;
30: import java.sql.Statement;
31:
32: /**
33: dBase read/write access <br>
34: @author Brian Jepson <bjepson@home.com>
35: @author Marcel Ruff <ruff@swand.lake.de> Added write access to dBase and JDK 2 support
36: */
37: public class dbfFileConnection extends tinySQLConnection {
38:
39: private dbfFileDatabaseMetaData myMetaData = null;
40:
41: /**
42: *
43: * Constructs a new JDBC Connection object.
44: *
45: * @exception SQLException in case of an error
46: * @param user the user name - not currently used
47: * @param u the url to the data source
48: * @param d the Driver object
49: *
50: */
51: public dbfFileConnection(String user, String u, Driver d)
52: throws SQLException {
53: super (user, u, d);
54: }
55:
56: /**
57: *
58: * Returns a new dbfFile object which is cast to a tinySQL
59: * object.
60: *
61: */
62: public tinySQL get_tinySQL() {
63:
64: // if there's a data directory, it will
65: // be everything after the jdbc:dbfFile:
66: //
67: if (url.length() > 13) {
68: String dataDir = url.substring(13);
69: return (tinySQL) new dbfFile(dataDir);
70: }
71:
72: // if there was no data directory specified in the
73: // url, then just use the default constructor
74: //
75: return (tinySQL) new dbfFile();
76:
77: }
78:
79: /**
80: * This method retrieves DatabaseMetaData
81: * @see java.sql.Connection#getMetData
82: * @exception SQLException
83: * @return a DatabaseMetaData object (conforming to JDK 2)
84: *
85: */
86: public DatabaseMetaData getMetaData() throws SQLException {
87: if (myMetaData == null)
88: myMetaData = new dbfFileDatabaseMetaData(this );
89: return (DatabaseMetaData) myMetaData;
90: }
91: }
|