Package java.sql

Examples of java.sql.DatabaseMetaData


    ResultSet rs = null;

    try {
      connection = dataSource.getConnection();

      DatabaseMetaData meta = connection.getMetaData();

      rs = meta.getTables(null, null, tableName, null);

      if (rs.next()) {
        return true;
      }
    } finally {
View Full Code Here


  public static ArrayList<String> listAllTables(Connection connection) throws SQLException {

    ResultSet rs = null;

    try {
      DatabaseMetaData meta = connection.getMetaData();

      rs = meta.getTables(null, null, null, null);

      ArrayList<String> tableList = new ArrayList<String>();

      while (rs.next()) {
View Full Code Here

  public static List<String> getTableColumns(Connection connection, String selectedTable) throws SQLException {

    ResultSet rs = null;

    try {
      DatabaseMetaData meta = connection.getMetaData();

      rs = meta.getColumns(null, null, selectedTable, null);

      ArrayList<String> columnNames = new ArrayList<String>();

      while (rs.next()) {
View Full Code Here

    try {

      connection = dataSource.getConnection();

      DatabaseMetaData meta = connection.getMetaData();

      rs = meta.getColumns(null, null, selectedTable, null);

      rs.last();

      return rs.getRow();
View Full Code Here

    public String[] findSchemaDetails(Connection conn)
    throws SQLException
    {
        String[] schemaDetails = new String[2];

        DatabaseMetaData dmd = conn.getMetaData();

        // Make sure the table name is in the correct case.
        // This is required by RDBMS such as PostgreSQL which allow creation in one format yet
        // actually store it in another.
        String table_name = identifier.getIdentifierName();
        if (storeMgr.getIdentifierFactory().getIdentifierCase() == IdentifierCase.LOWER_CASE ||
            storeMgr.getIdentifierFactory().getIdentifierCase() == IdentifierCase.LOWER_CASE_QUOTED)
        {
            table_name = table_name.toLowerCase();
        }
        else if (storeMgr.getIdentifierFactory().getIdentifierCase() == IdentifierCase.UPPER_CASE ||
            storeMgr.getIdentifierFactory().getIdentifierCase() == IdentifierCase.UPPER_CASE_QUOTED)
        {
            table_name = table_name.toUpperCase();
        }

        // Utilise default catalog/schema if available and applicable
        String catalog_name = storeMgr.getStringProperty("datanucleus.mapping.Catalog");
        String schema_name = storeMgr.getStringProperty("datanucleus.mapping.Schema");
        if (!dba.supportsOption(DatastoreAdapter.CATALOGS_IN_TABLE_DEFINITIONS))
        {
            catalog_name = null;
        }
        if (!dba.supportsOption(DatastoreAdapter.SCHEMAS_IN_TABLE_DEFINITIONS))
        {
            schema_name = null;
        }

        // Find the schema details
        ResultSet rs = dmd.getTables(catalog_name,schema_name,table_name,null);
        try
        {
            if (!rs.next())
            {
                throw new NucleusDataStoreException(LOCALISER.msg("057027",identifier));
View Full Code Here

    public DatastoreAdapter getDatastoreAdapter(ClassLoaderResolver clr, Connection conn,
            String adapterClassName, PluginManager pluginMgr)
    throws SQLException
    {
        DatastoreAdapter adapter = null;
        DatabaseMetaData metadata = conn.getMetaData();

        // Get a new adapter
        adapter = getNewDatastoreAdapter(clr, metadata, adapterClassName, pluginMgr);
        if (adapter == null)
        {
View Full Code Here

    String sDbVersion="";
    DBVersion db=null;
    Exception lastError = null;
    String shortVersion="";
    try{
      DatabaseMetaData meta = conn.getConnection().getMetaData();
      try{
        major = meta.getDatabaseMajorVersion();
        minor = meta.getDatabaseMinorVersion();
        conn.setMajorVersion(major);
        conn.setMinorVersion(minor);
        log.debug3("DatabaseMajorVersion: "+major);
        log.debug3("DatabaseMinorVersion: "+minor);
      } catch (AbstractMethodError ex){
        lastError=new Exception(ex);
      } catch (Exception ex){
        lastError = ex;
      }
      try{
        sDbVersion = meta.getDatabaseProductVersion();
        conn.setProductVersion(sDbVersion);
        log.debug3("DatabaseProductVersion: "+sDbVersion);
      } catch (Exception ex){
        lastError = ex;
      }
View Full Code Here

            stmt.execute("set files write delay 10000 millis");
            stmt.execute("set files log size " + 200);

            stmt.execute("set files backup increment true");

            DatabaseMetaData metaData = con.getMetaData();
            ResultSet        rs = metaData.getTables(null, null, "B", null);
            boolean          schemaExists;

            try {
                schemaExists = rs.next();
            } finally {
View Full Code Here

     * @throws SQLException Thrown if an error occurs
     */
    public ResultSet getColumns(Connection conn, String catalog, String schema, String table, String columnNamePattern)
    throws SQLException
    {
        DatabaseMetaData dmd = conn.getMetaData();
        return dmd.getColumns(catalog, schema, table, columnNamePattern);
    }
View Full Code Here

            try {
                if (c.isClosed()) {
                    s = "connection is closed";
                }
                else {
                    DatabaseMetaData meta = c.getMetaData();
                    if (meta != null) {
                        StringBuffer sb = new StringBuffer();
                        sb.append(meta.getURL());
                        sb.append(", UserName=");
                        sb.append(meta.getUserName());
                        sb.append(", ");
                        sb.append(meta.getDriverName());
                        s = sb.toString();
                    }
                }
            }
            catch (SQLException ex) {
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.