001: package org.mandarax.jdbc.client;
002:
003: /*
004: * Copyright (C) 1999-2004 <a href="mailto:mandarax@jbdietrich.com">Jens Dietrich</a>
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: */
020:
021: import java.sql.*;
022:
023: import org.mandarax.jdbc.*;
024: import org.mandarax.jdbc.rpc.*;
025:
026: /**
027: * Meta data implementation.
028: * @author <A HREF="mailto:mandarax@jbdietrich.com">Jens Dietrich</A>
029: * @version 3.3.2 <29 December 2004>
030: * @since 3.0
031: */
032:
033: public class DatabaseMetaDataImpl extends AbstractDatabaseMetaDataImpl {
034: private Transport transport = null;
035:
036: /**
037: * Constructor.
038: * @param url the database url
039: * @param connection the connection used to produce this object
040: * @param kb the knowledge base
041: */
042: DatabaseMetaDataImpl(String url, ConnectionImpl connection,
043: Transport transport) {
044: super (url, connection);
045: this .transport = transport;
046: }
047:
048: /**
049: * Retrieves the user name as known to this database.
050: * @return java.lang.String
051: * @throws java.sql.SQLException
052: */
053: public String getUserName() throws SQLException {
054: return System.getProperty("user.name");
055: }
056:
057: /**
058: * Retrieves the name of this JDBC driver.
059: * @return JDBC driver name
060: * @throws java.sql.SQLException
061: */
062: public String getDriverName() throws SQLException {
063: return "mandarax jdbc net driver";
064: }
065:
066: /**
067: * Retrieves this JDBC driver's major version number.
068: * @return JDBC driver major version number
069: */
070: public int getDriverMajorVersion() {
071: return 1;
072:
073: }
074:
075: /**
076: * Retrieves this JDBC driver's minor version number.
077: * @return JDBC driver minor version number
078: */
079: public int getDriverMinorVersion() {
080: return 0;
081: }
082:
083: /**
084: * Retrieves whether this database stores tables in a local file.
085: * @return boolean
086: * @throws java.sql.SQLException
087: */
088: public boolean usesLocalFiles() throws SQLException {
089: return false;
090: }
091:
092: /**
093: * Get the id of the associated connection.
094: * @return an id
095: */
096: private String getConnectionId() throws SQLException {
097: Connection con = this .getConnection();
098: return ((ClientObject) con).getId();
099: }
100:
101: /**
102: * Retrieves a description of table columns available in the specified catalog.
103: * @param catalog
104: * @param schemaPattern
105: * @param tableNamePattern
106: * @param columnNamePattern
107: * @return java.sql.ResultSet
108: * @throws java.sql.SQLException
109: */
110: public ResultSet getColumns(String catalog, String schemaPattern,
111: String tableNamePattern, String columnNamePattern)
112: throws SQLException {
113: Call call = new Call(getConnectionId(),
114: "Connection_getMetaData_getColumns", new Object[] {
115: catalog, schemaPattern, tableNamePattern,
116: columnNamePattern });
117: return QueryHelper.executeQuery(transport, call, 10, this );
118: }
119:
120: /**
121: * Retrieves a description of the tables available in the given catalog.
122: * @param catalog
123: * @param schemaPattern
124: * @param tableNamePattern
125: * @param types
126: * @return java.sql.ResultSet
127: * @throws java.sql.SQLException
128: */
129: public ResultSet getTables(String catalog, String schemaPattern,
130: String tableNamePattern, String[] types)
131: throws SQLException {
132: Call call = new Call(getConnectionId(),
133: "Connection_getMetaData_getTables",
134: new Object[] { catalog, schemaPattern,
135: tableNamePattern, types });
136: return QueryHelper.executeQuery(transport, call, 10, this);
137: }
138:
139: }
|