Package java.sql

Examples of java.sql.DatabaseMetaData


  {
    final String key = "getJDBCVersion";
    Integer value = (Integer) _cache.get(key);
    if (value == null)
    {
      DatabaseMetaData md = privateGetJDBCMetaData();
      int major = md.getJDBCMajorVersion();
      int minor = md.getJDBCMinorVersion();
      int vers = (major * 100) + minor;
      value = Integer.valueOf(vers);
      _cache.put(key, value);
    }
    return value.intValue();
View Full Code Here


  /**
   * @see net.sourceforge.squirrel_sql.fw.sql.ISQLDatabaseMetaData#getDataTypes()
   */
  public synchronized DataTypeInfo[] getDataTypes() throws SQLException
  {
    final DatabaseMetaData md = privateGetJDBCMetaData();
    final ArrayList<DataTypeInfo> list = new ArrayList<DataTypeInfo>();
    final ResultSet rs = md.getTypeInfo();
    try
    {
      ResultSetColumnReader rdr = new ResultSetColumnReader(rs);
      while (rdr.next())
      {
View Full Code Here

   *      java.lang.String, java.lang.String, net.sourceforge.squirrel_sql.fw.sql.ProgressCallBack)
   */
  public synchronized IProcedureInfo[] getProcedures(String catalog, String schemaPattern,
    String procedureNamePattern, ProgressCallBack progressCallBack) throws SQLException
  {
    DatabaseMetaData md = privateGetJDBCMetaData();
    ArrayList<ProcedureInfo> list = new ArrayList<ProcedureInfo>();
    ResultSet rs = md.getProcedures(catalog, schemaPattern, procedureNamePattern);
    if (rs != null)
    {
      int count = 0;
      try
      {
View Full Code Here

  {
    final String key = "getTableTypes";
    String[] value = (String[]) _cache.get(key);
    if (value != null) { return value; }

    final DatabaseMetaData md = privateGetJDBCMetaData();

    // Use a set rather than a list as some combinations of MS SQL and the
    // JDBC/ODBC return multiple copies of each table type.
    final Set<String> tableTypes = new TreeSet<String>();
    final ResultSet rs = md.getTableTypes();
    if (rs != null)
    {
      try
      {
        while (rs.next())
View Full Code Here

   */
  public synchronized ITableInfo[] getTables(String catalog, String schemaPattern, String tableNamePattern,
    String[] types, ProgressCallBack progressCallBack) throws SQLException
  {

    final DatabaseMetaData md = privateGetJDBCMetaData();
    final String dbDriverName = getDriverName();
    Set<ITableInfo> list = new TreeSet<ITableInfo>();

    /* work-around for this driver, which must have "dbo" for schema.  The
     * JConnect family of drivers appears to not be affected and can accept a
     * null schema, which is necessary to find tables in other schemas, within
     * the same catalog.  Similarly, jTDS 1.2.2 doesn't require this, yet it
     * doesn't return non-dbo schema tables, unfortunately.
     */
    if (dbDriverName.equals(IDriverNames.FREE_TDS) && schemaPattern == null)
    {
      schemaPattern = "dbo";
    }
    if (dbDriverName.equals(IDriverNames.AS400) && schemaPattern == null)
    {
      schemaPattern = "*ALLUSR";
    }

    // Add begin
    if (catalog == null && DriverMatch.isComHttxDriver(_conn))
    {
      String[] catalogs = getCatalogs();
      if (catalogs != null)
      {
        for (int i = 0; i < catalogs.length; i++)
        {
          ITableInfo[] tables =
            getTables(catalogs[i], schemaPattern, tableNamePattern, types, progressCallBack);
          for (int j = 0; j < tables.length; j++)
          {
            list.add(tables[j]);
          }
        }
        return list.toArray(new ITableInfo[list.size()]);
      }
    }
    // Add end

    Map<String, ITableInfo> nameMap = null;
    ResultSet superTabResult = null;
    ResultSet tabResult = null;
    try
    {
      if (supportsSuperTables)
      {
        try
        {
          superTabResult = md.getSuperTables(catalog, schemaPattern, tableNamePattern);
          // create a mapping of names if we have supertable info, since
          // we need to find the ITableInfo again for re-ordering.
          if (superTabResult != null && superTabResult.next())
          {
            nameMap = new HashMap<String, ITableInfo>();
          }
        }
        catch (Throwable th)
        {
          s_log.debug("DBMS/Driver doesn't support getSupertables(): " + th.getMessage());
          supportsSuperTables = false;
        }
      }
      // store all plain table info we have.
      tabResult = md.getTables(catalog, schemaPattern, tableNamePattern, types);
      int count = 0;
      while (tabResult != null && tabResult.next())
      {
        ITableInfo tabInfo =
          new TableInfo(tabResult.getString(1), tabResult.getString(2), tabResult.getString(3),
View Full Code Here

   *      java.lang.String, java.lang.String, int[])
   */
  public synchronized IUDTInfo[] getUDTs(String catalog, String schemaPattern, String typeNamePattern,
    int[] types) throws SQLException
  {
    DatabaseMetaData md = privateGetJDBCMetaData();
    ArrayList<UDTInfo> list = new ArrayList<UDTInfo>();
    checkForInformix(catalog);
    ResultSet rs = md.getUDTs(catalog, schemaPattern, typeNamePattern, types);
    try
    {
      final int[] cols = new int[] { 1, 2, 3, 4, 5, 6 };
      DialectType dialectType = DialectFactory.getDialectType(this);
      final ResultSetReader rdr = new ResultSetReader(rs, cols, dialectType);
View Full Code Here

    boolean computeWidths) throws DataSetException
  {
    ResultSet rs = null;
    try
    {
      DatabaseMetaData md = privateGetJDBCMetaData();
      final String columns = DialectFactory.isMySQL(this) ? "%" : null;

      rs = md.getColumnPrivileges(ti.getCatalogName(), ti.getSchemaName(), ti.getSimpleName(), columns);
      ResultSetDataSet rsds = new ResultSetDataSet();
      rsds.setResultSet(rs, columnIndices, computeWidths, DialectFactory.getDialectType(this));
      return rsds;
    }
    catch (SQLException e)
View Full Code Here

  public synchronized IDataSet getProcedureColumnsDataSet(IProcedureInfo ti) throws DataSetException
  {
    ResultSet rs = null;
    try
    {
      DatabaseMetaData md = privateGetJDBCMetaData();
      rs = md.getProcedureColumns(ti.getCatalogName(), ti.getSchemaName(), ti.getSimpleName(), "%");
      ResultSetDataSet rsds = new ResultSetDataSet();
      rsds.setResultSet(rs, DialectFactory.getDialectType(this));
      return rsds;
    }
    catch (SQLException e)
View Full Code Here

    boolean computeWidths) throws DataSetException
  {
    ResultSet rs = null;
    try
    {
      DatabaseMetaData md = privateGetJDBCMetaData();
      rs = md.getTablePrivileges(ti.getCatalogName(), ti.getSchemaName(), ti.getSimpleName());
      ResultSetDataSet rsds = new ResultSetDataSet();
      rsds.setResultSet(rs, columnIndices, computeWidths, DialectFactory.getDialectType(this));
      return rsds;
    }
    catch (SQLException e)
View Full Code Here

  public synchronized IDataSet getVersionColumnsDataSet(ITableInfo ti) throws DataSetException
  {
    ResultSet rs = null;
    try
    {
      DatabaseMetaData md = privateGetJDBCMetaData();
      rs = md.getVersionColumns(ti.getCatalogName(), ti.getSchemaName(), ti.getSimpleName());
      ResultSetDataSet rsds = new ResultSetDataSet();
      rsds.setResultSet(rs, DialectFactory.getDialectType(this));
      return rsds;
    }
    catch (SQLException e)
View Full Code Here

TOP

Related Classes of java.sql.DatabaseMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.