Getting the table names in an MS Access database

Hi,
I am new to JDBC and making a client/server application that updates a MS Access database through jdbc:odbc.
I need to get a list of existing user tables in the db. I have found a great document on the net which has the code, however the code doesn't work. I have tried different ways and looked every where with no success. (link to the doco: http://www-128.ibm.com/developerworks/opensource/library/j-jdbc-objects/)
Here is my dbManager class that handles all db related services in my application. I would appreciate any help I can get as I have exhusted all my avenues.
Thanks
Sep,
* dbManager.java
* Created on 31 October 2005, 10:20
* To change this template, choose Tools | Options and locate the template under
* the Source Creation and Management node. Right-click the template and choose
* Open. You can then make changes to the template in the Source Editor.
import java.io.*;
import java.sql.*;
import java.util.regex.*;
* @author AUMahdavSe
public class dbManager {
    /** Constant Declaration                */
    public static final String Driver = "sun.jdbc.odbc.JdbcOdbcDriver";
    public static final
        String sqlCreateTable = "create table TABLENAME (" +
            "name varchar (100)," +
            "surname varchar(100)," +
            "computerType integer," +
            "computerNAL varchar(20)," +
            "haveMonitor integer," +
            "monitorNAL varchar (20)," +
            "auditDate varchar(10) );";
    public static final String sqlUpdateTable = "insert into TABLENAME values" +
            " (NAMEHOLDER, SURNAMEHOLDER, COMPTYPE, COMPNAL, HAVEMON, MONNAL);";
    /** Attributes                          */
    private String dbURL = "jdbc:odbc:";
    private String Username = "admin";  // user input
    private String Password = "purina123";  // user input
    private String ODBCDataSource;  // config file
    private String dbPath;  // set through config file or defaults to current folder
    private String configFile = "config.txt"; // set either at commandline or defaults to current folder
    private Connection con = null;
    private Statement stmt = null;
    private ResultSet tables;
    private DatabaseMetaData dma;
    private ResultSetMetaData rsmd;
    private String CurrentAuditTable = "TestTable2";
    int numCols, i;
    /** Set Methodes                        */
    public void setUsername( String usr ) {
        this.Username = usr;
    public void setPassword( String pswd ) {
        this.Password = pswd;
    public void setDbPath( String path ) {
        this.dbPath = path;
    public void setODBCDataSource( String ds ) {
        this.ODBCDataSource = ds;
    public void setDbURL( String dsname ) {
        this.dbURL = this.dbURL + dsname;
    /** Get Methodes                        */
    public String getDriver() {
        return this.Driver;
    // can be run only after a connection obj is setup
    public void getMDA() {
        try {
            this.dma = this.con.getMetaData();           
        catch (SQLException ex) {
            System.err.println("database connection: " + ex.getMessage());
    public void getDBTables() {
        //now dump out the names of the tables in the database
        String[] types = new String[1];
        types[0] = "TABLES"; //set table type mask
        //note the %-sign is a wild card (not '*')
        try {
            this.tables = this.dma.getTables(null, null, "%", types);
            dumpResults("--Tables--");
            this.tables.close();
            //this.listTables();
        catch (SQLException ex) {
            System.err.println("database connection: " + ex.getMessage());
        // listing tables
        /*int count = 0;
        int numCols = 0;
        //ResultSetMetaData rsmd;
        try {
            System.out.println("Listing db tables ...");
            //this.tables.beforeFirst();
            rsmd = this.tables.getMetaData();
            numCols = rsmd.getColumnCount();
            System.out.println("number of cols: " + numCols);
            boolean more = this.tables.first();
            System.out.println("this is why: " + more);
            while ( more ) {
                count++;
                for (int i = 1; i <= numCols; i++)
                    System.out.print( "Table-" + count + " -> " + this.tables.getString(count)+"    " );
                System.out.println();
                more = this.tables.next();
        catch ( SQLException ex ) {
            System.out.println( "problem listing db tables: " + ex.getMessage() );
    /** Other Methodes                      */
    // Initialize the db parameters, like driver, username, passwd, etc.
    public void dbInitialize() {
        // load configuration from config.txt (dbPath and ODBC Data Source name)
        this.loadDbConfig();
        // loadDriver
        this.loadDriver();
        // get username and password for the ODBC from user
        this.getDSSecurity();
        // populate dbURL, username and password
        this.setDbURL( this.ODBCDataSource );
        // connect to db
        this.dbConnect();
        // get db metadata
        this.getMDA();
        // get a list of tables in db
        this.getDBTables();
    // load JDBC driver
    public void loadDriver() {
        try {
            Class.forName( getDriver() );
        } catch (Exception e) {
            System.out.println("Failed to load JDBC/ODBC driver.");
            return;
    // connects to db and create a Connection obj and a Statement obj
    public void dbConnect() {
       try {
            this.con = DriverManager.getConnection (
                this.dbURL,
                this.Username,
                this.Password);
            this.stmt = con.createStatement();
        } catch (Exception e) {
            System.err.println("problems connecting to "+this.dbURL);
    // creates table tblname in db
    public void CreateTable( String tblname ) {
        try {
            String sqlcommand = mergeTblName(sqlCreateTable, tblname);
            this.stmt.execute( sqlcommand );
        catch (SQLException ex) {
            System.err.println("problems with SQL statement sent to "+this.dbURL+
                ": "+ex.getMessage());
            System.out.println("SQL Command: " + mergeTblName(sqlCreateTable, tblname) );
    // updates db with new record(s) by executing the SQL query sqlstmt
    // and closes db connection
    public void dbUpdate( String sqlstmt ) {
        try {
            // execute SQL commands to create table, insert data
            this.stmt.execute( sqlstmt );
            this.con.close();
        } catch (Exception e) {
            System.err.println("problems with SQL sent to "+this.dbURL+
                ": "+e.getMessage());
    // list all user tables in the db
    public void listTables() {
        //now dump out the names of the tables in the database
        int count = 0;       
        try {
            System.out.println("Listing db tables ...");
            //this.tables.beforeFirst();
            while ( this.tables.next() ) {
                count++;
                System.out.print( "Table-" + count + " -> " + this.tables.getString(1) );
                System.out.println();
        catch ( SQLException ex ) {
            System.out.println( "problem listing db tables: " + ex.getMessage() );
    // checks whether tbname exist in db as a table
    // this function has to be called after dbConnect
    public boolean tableExists( String tbname ) {
        boolean tbexists = false;
        //get the database metadata
        try {
            dma = con.getMetaData();           
        catch (SQLException ex) {
            System.err.println("database connection: " + ex.getMessage());
        //now dump out the names of the tables in the database
        String[] types = new String[1];
        types[0] = "TABLES"; //set table type mask
        //note the %-sign is a wild card (not '*')
        try {
            tables = dma.getTables(null, null, "%", types);
        catch (SQLException ex) {
            System.err.println("database connection: " + ex.getMessage());
        try {
            while ( tables.next() ) {
                if ( tbname.equalsIgnoreCase( tables.getString(1) ) ) {
                    tbexists = true;
        catch ( SQLException ex ) {
            System.err.println("database connection: " + ex.getMessage());
        return tbexists;
    // merge tablename using REGEX
    public String mergeTblName( String sqlcommand, String tbname ) {
        String REGEX = "TABLENAME";
        String INPUT = sqlcommand;
        String REPLACE = tbname;
        Pattern p = Pattern.compile(REGEX);
        Matcher m = p.matcher(INPUT); // get a matcher object
        INPUT = m.replaceAll(REPLACE);
        //System.out.println(INPUT);
        return INPUT;
    // merge feildnames specific terms using REGEX
    public String mergeFldName( Message msg ) {
        String sqlcommand;
        sqlcommand = "insert into TABLENAME values" +
                " ('" + msg.getName() + "', '" + msg.getSurname() + "', " +
                msg.getComputerType() + ", '" + msg.getComputerNAL() + "', " +
                msg.getHaveMonitor() + ", '" + msg.getMonitorNAL() + "', '" +
                msg.getDateOfMsg() + "');";
        sqlcommand = mergeTblName( sqlcommand, CurrentAuditTable );
        return sqlcommand;
    // get users input char
    /**public char getChar() {
        int i = System.in.read();
        while (i != -1) {
          // here's your character
          char c = (char) i;
          i = System.in.read();
        return (char) i;
    // load the config parameters from config.txt
    public void loadDbConfig() {
        // make a file obj pointing to the config file config.txt
        File configFile = new File( this.configFile );
        //...checks on configFile are elided
        StringBuffer contents = new StringBuffer();
        //declared here only to make visible to finally clause
        BufferedReader input = null;
        try {
          //use buffering
          //this implementation reads one line at a time
          input = new BufferedReader( new FileReader(configFile) );
          String line = null; //not declared within while loop
          int count = 0;
          while (( line = input.readLine()) != null){
            //first line in config file is dbPath
            if(count == 0) this.setDbPath( line.trim() );
            //second line in config file is ODBCDataSource
            if(count == 1) this.setODBCDataSource( line.trim() );
            count++; 
            //contents.append(line);
            //contents.append(System.getProperty("line.separator"));
        catch (FileNotFoundException ex) {
            System.err.println("the file congif.txt cannot be found ...");
            System.err.print("Enter the path to db file (e.g. c:\\temp): ");
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            //  read the db path from the command-line; need to use try/catch with the
            //  readLine() method
            try {
                this.setDbPath( br.readLine() );
            catch (IOException ioe) {
                System.out.println("IO error trying to read user input.");
                System.exit(1);
            System.err.print("Enter the name of the ODBC Data Source: ");
            //  read the ODBC Data Source name from the command-line; need to use try/catch with the
            //  readLine() method
            try {
                this.setODBCDataSource( br.readLine() );
            catch (IOException ioe) {
                System.out.println("IO error trying to read user input.");
                System.exit(1);
            ex.printStackTrace();
        catch (IOException ex){
          //ex.printStackTrace();
        finally {
          try {
            if (input!= null) {
              //flush and close both "input" and its underlying FileReader
              input.close();
          catch (IOException ex) {
            //ex.printStackTrace();
        //return contents.toString();
    // get datasource security details i.e. username and password
    public void getDSSecurity() {
        // get username
        System.out.print("Enter username for the ODBC DataSource: ");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //  read the username from the command-line; need to use try/catch with the
        //  readLine() method
        try {
            this.setUsername( br.readLine() );
        catch (IOException ioe) {
            System.out.println("IO error trying to read username.");
            System.exit(1);
        // get password
        System.out.print("Enter password: ");
        //  read the username from the command-line; need to use try/catch with the
        //  readLine() method
        try {
            this.setPassword( br.readLine() );
        catch (IOException ioe) {
            System.out.println("IO error trying to read password.");
            System.exit(1);
    private void dumpResults(String head)
     //this is a general routine to print out
     //column headers and the contents of each column
     System.out.println(head);
      try
       //get the number of columns from the metadata
       this.rsmd = this.tables.getMetaData();      
       numCols = this.rsmd.getColumnCount();
       //print out the column names
       for (i = 1; i<= numCols; i++)
         System.out.print(rsmd.getColumnName(i)+"     ");
       System.out.println();
       //print out the column contents
       boolean more = this.tables.next();
       while (more)
         for (i = 1; i <= numCols; i++)
           System.out.print(this.tables.getString(i)+"     ");
         System.out.println();
         more = this.tables.next();
     catch(Exception e)
       {System.out.println(e.getMessage());}
    /** Creates a new instance of dbManager */
    public dbManager() {
        this.dbInitialize();
}here is the result when I make a new dbManager obj from my server class which is a multithreaded one.
H:\java>java EchoServer
Enter username for the ODBC DataSource: admin
Enter password: purina123
Tables
TABLE_CAT TABLE_SCHEM TABLE_NAME TABLE_TYPE REMARKS
Listening for clients on 12111...
here is the code of my server class called EchoServer:
import java.net.*;
import java.io.*;
public class EchoServer
    ServerSocket m_ServerSocket;
    dbManager haDB;
    public EchoServer() 
        // db methods to setup a jdbc connection to the database
        haDB = new dbManager();
        // list tables
        //haDB.listTables();       
        //haDB.getDBTables();
        // create table
        //haDB.CreateTable("TestTable2");
        // update table
        // server code
        try
            // Create the server socket.
            m_ServerSocket = new ServerSocket(12111);
        catch(IOException ioe)
            System.out.println("Could not create server socket at 12111. Quitting.");
            System.exit(-1);
        System.out.println("Listening for clients on 12111...");
        // Successfully created Server Socket. Now wait for connections.
        int id = 0;
        while(true)
            try
                // Accept incoming connections.
                Socket clientSocket = m_ServerSocket.accept();
                // accept() will block until a client connects to the server.
                // If execution reaches this point, then it means that a client
                // socket has been accepted.
                // For each client, we will start a service thread to
                // service the client requests. This is to demonstrate a
                // multithreaded server, although not required for such a
                // trivial application. Starting a thread also lets our
                // EchoServer accept multiple connections simultaneously.
                // Start a service thread
                ClientServiceThread cliThread = new ClientServiceThread(clientSocket, id++, haDB);
                cliThread.start();
            catch(IOException ioe)
                System.out.println("Exception encountered on accept. Ignoring. Stack Trace :");
                ioe.printStackTrace();
    public static void main (String[] args)
        new EchoServer();    
    class ClientServiceThread extends Thread
        Socket m_clientSocket;        
        int m_clientID = -1;
        dbManager m_db;
        boolean m_bRunThread = true;
        ClientServiceThread(Socket s, int clientID, dbManager db)
            m_clientSocket = s;
            m_clientID = clientID;
            m_db = db;
        public void run()
            // Obtain the input stream and the output stream for the socket
            // A good practice is to encapsulate them with a BufferedReader
            // and a PrintWriter as shown below.
            BufferedReader in = null; 
            PrintWriter out = null;
            Message msg = new Message();
            // Print out details of this connection
            System.out.println("Accepted Client : ID - " + m_clientID + " : Address - " + 
                             m_clientSocket.getInetAddress().getHostName());
            try
                in = new BufferedReader(new InputStreamReader(m_clientSocket.getInputStream()));
                out = new PrintWriter(new OutputStreamWriter(m_clientSocket.getOutputStream()));
                // At this point, we can read for input and reply with appropriate output.
                // Run in a loop until m_bRunThread is set to false
                while(m_bRunThread)
                    // read incoming stream
                    String clientCommand = in.readLine();
                    if ( clientCommand.indexOf(",") != -1 ) {
                        msg.deserialize( clientCommand );
                        System.out.println("SQL command: " + m_db.mergeFldName(msg) );
                        m_db.dbUpdate( m_db.mergeFldName(msg) );
                        //System.out.println("Name :" + msg.getName() );
                        //System.out.println("Surname :" + msg.getSurname() );
                        //System.out.println("ComputerType :" + msg.getComputerType() );
                        //System.out.println("ComputerNAL :" + msg.getComputerNAL() );
                        //System.out.println("HaveMonitor :" + msg.getHaveMonitor() );
                        //System.out.println("Monitor NAL :" + msg.getMonitorNAL() );
                        //System.out.println("AuditDate :" + msg.getDateOfMsg() );                       
                    System.out.println("Client Says :" + clientCommand);
                    if(clientCommand.equalsIgnoreCase("quit"))
                        // Special command. Quit this thread
                        m_bRunThread = false;   
                        System.out.print("Stopping client thread for client : " + m_clientID);
                    else
                        // Echo it back to the client.
                        out.println(clientCommand);
                        out.flush();
            catch(Exception e)
                e.printStackTrace();
            finally
                // Clean up
                try
                    in.close();
                    out.close();
                    m_clientSocket.close();
                    System.out.println("...Stopped");
                catch(IOException ioe)
                    ioe.printStackTrace();
}

I find that taking any problem and reducing it to the simplest thing is the best way to approach it.
Why you had to post all that bloody code (especially since you didn't write it) is beyond me.
This will list all the tables in an Access database (or any other, for that matter):
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.jdom.Element;
import org.jdom.Document;
import org.jdom.output.XMLOutputter;
public class TableLister
    public static final String DRIVER   = "sun.jdbc.odbc.JdbcOdbcDriver";
    public static final String DATABASE = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\Edu\\Java\\Forum\\DataConnection.mdb";
    public static final String USERNAME = "admin";
    public static final String PASSWORD = "";
    public static void main(String [] args)
        try
            String driver           = ((args.length > 0) ? args[0] : DRIVER);
            String url              = ((args.length > 1) ? args[1] : DATABASE);
            String username         = ((args.length > 2) ? args[2] : USERNAME);
            String password         = ((args.length > 3) ? args[3] : PASSWORD);
            Class.forName(driver);
            Connection conn         = DriverManager.getConnection(url, username, password);
            DatabaseMetaData meta   = conn.getMetaData();
            // Bring back ALL tables and views, including SYSTEM tables.
            ResultSet tables        = meta.getTables(null, null, null, null);
            ResultSetMetaData rsmd  = tables.getMetaData();
            int numColumns          = rsmd.getColumnCount();
            List columnNames        = new ArrayList();
            for (int j = 0; j < numColumns; ++j)
                columnNames.add(rsmd.getColumnName(j+1));
            Element root = new Element("tables");
            int tableCount = 0;
            while (tables.next())
                Element table = new Element("table");
                table.setAttribute("id", Integer.toString(++tableCount));
                for (int j = 0; j < numColumns; ++j)
                    Element column = new Element((String)columnNames.get(j));
                    column.setText(tables.getString((String)columnNames.get(j)));
                    table.addContent(column);
                root.addContent(table);
            conn.close();
            Document doc = new Document(root);
            XMLOutputter outputter = new XMLOutputter("   ", true);
            System.out.println(outputter.outputString(doc));
        catch (ClassNotFoundException e)
            System.err.println("Couldn't load JDBC driver class");
            e.printStackTrace();
        catch (SQLException e)
            System.err.println("SQL state: " + e.getSQLState());
            System.err.println("SQL error: " + e.getErrorCode());
            e.printStackTrace();
        catch (Exception e)
            e.printStackTrace();
}Run it and see if it works for you. If it does, put the essence of the code into your stuff.
%

Similar Messages

  • How to get the table name in the trigger definition without hard coding.

    CREATE  TRIGGER db.mytablename
    AFTER UPDATE,INSERT
    AS
        INSERT INTO table1(col1)
        SELECT InsRec.col1   
        FROM
        INSERTED Ins
       --Below i am calling one sp for which i have to pass the table name
       EXEC myspname 'tablename'
      In the above trigger,presently i am hard coding the tablename
      but is it possible to get the table name dynamically on which the trigger is defined in order to avoid hard coding the table name

    I really liked your audit table concept.  You inspired me to modify it so that, the entire recordset gets captured and added a couple of other fields.  Wanted to share my end result.
    USE [YourDB]
    GO
    /****** Object: Trigger [dbo].[iudt_AutoAuditChanges] Script Date: 10/18/2013 12:49:55 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER TRIGGER [dbo].[iudt_AutoAuditChanges]
    ON [dbo].[YourTable]
    AFTER INSERT,DELETE,UPDATE
    AS
    BEGIN
    SET NOCOUNT ON;
    Declare @v_AuditID bigint
    IF OBJECT_ID('dbo.AutoAudit','U') IS NULL BEGIN
    CREATE TABLE [dbo].[AutoAudit]
    ( [AuditID] bigint identity,
    [AuditDate] DateTime,
    [AuditUserName] varchar(128),
    [TableName] varchar(128) NULL,
    [OldContent] XML NULL,
    [NewContent] XML NULL
    ALTER TABLE dbo.AutoAudit ADD CONSTRAINT
    PK_AutoAudit PRIMARY KEY CLUSTERED
    [AuditID]
    ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    CREATE NONCLUSTERED INDEX [idx_AutoAudit_TableName_AuditDate] ON [dbo].[AutoAudit]
    ( [TableName] ASC,
    [AuditDate] ASC
    )WITH (STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    END
    Select * Into #AuditDeleted from deleted
    Select * Into #AuditInserted from inserted
    While (Select COUNT(*) from #AuditDeleted) > 0 OR (Select COUNT(*) from #AuditInserted) > 0
    Begin
    INSERT INTO [dbo].[AutoAudit]
    ( [AuditDate], [AuditUserName], [TableName], [OldContent], [NewContent])
    SELECT
    GETDATE(),
    SUSER_NAME(),
    [TableName]=object_name([parent_obj]),
    [OldContent]=CAST((SELECT TOP 1 * FROM #AuditDeleted D FOR XML RAW) AS XML),
    [NewContent]=CAST((SELECT TOP 1 * FROM #AuditInserted I FOR XML RAW) AS XML)
    FROM sysobjects
    WHERE
    [xtype] = 'tr'
    and [name] = OBJECT_NAME(@@PROCID)
    Set @v_AuditID = SCOPE_IDENTITY()
    Delete from AutoAudit
    Where AuditID = @v_AuditID
    AND Convert(varchar(max),oldContent) = Convert(varchar(max),NewContent)
    Delete top(1) from #AuditDeleted
    Delete top(1) from #AuditInserted
    End
    END

  • How to get the table name and bind columns names in an INSERT statement ?

    I have an INSERT statement with input parameters (for example
    INSERT INTO my_table VALUES (:a, :a, :a)) and I want to know
    without parsing the statement which is the name of table to
    insert to and the corresponding columns.
    This is needed to generate the SELECT FOR UPDATE statement to
    refetch a BLOB before actually writing to it. The code does not
    know in advance the schema (generic code).
    Thanks in advance,
    Joseph Canedo

    Once you have prepared your statement, you can execute the
    statement with the OCI_DESCRIBE_ONLY mode before binding any
    columns. Then you can use OCIParamGet to find out about each
    column (column index is 1-based). You should get OCI_NO_DATA or
    ORA-24334 if there are no more columns in the statement. Note
    that the parameter descriptor from OCIParamGet is
    allocated/freed internally by OCI; you do not need to manage it
    explicitly. The parameter descriptor is passed to OCIAttrGet in
    order to obtain for instance the maximum size of data in the
    column OCI_ATTR_DATA_SIZE. You can also get the column name in
    this way, although I do not remember the #define off the top of
    my head. Getting the table name appears to be much more
    difficult; I have never had to do that yet. Good luck. -Ralph

  • How to get the table name of a field in a result set

    hi!
    i have a simple sql query as
    select tbl_customerRegistration.*, tbl_customerAddress.address from tbl_customerRegistration, tbl_customerAddress where tbl_customerAddress.customer_id = tbl_customerRegistration.customer_ID
    this query executes well and gets data from the database when i get ResultsetMetaData from my result set (having result of above query) i am able to get the field name as
    ResultSetMetaData rsmd = rs.getMetaData();//rs is result set
    String columnName = rsmd.getColumnName(1);
    here i get columnName = "Customer_id"
    but when i try to get the tabel name from meta data as
    String tableName = rsmd.getTableName(1); i get empty string in table name....
    i want to get the table name of the respective field here as it is very important to my logic.....
    how can i do that.....
    please help me in that regard as it is very urgent
    thanks in advance
    sajjad ahmed paracha
    you may also see the discussion on following link
    http://forum.java.sun.com/thread.jspa?threadID=610200&tstart=0

    So far as I'm aware, you can't get metadata information about the underlying tables in a query from Oracle and/or the Oracle drivers. I suspect, in fact, that the driver would have to have its own SQL parser to get this sort of information.
    I'm curious though-- how do you have application logic that depends on the name of the source table but not know in the application what table is involved? Could you do something "cheesy" like
    SELECT 'tbl_customerRegistration' AS tbl1_name,
           tbl_customerRegistration.*
    ...Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Get the Table name by providing the Sequence name

    Hello,
    I wish to retrieve the table name to which the sequence is related.
    I understand that when the sequence was created, no reference is mentioned to any table. The sequence may be used across many tables.
    But the DB definitely knows internally how many tables are referencing the particular sequence.
    So, can anyone help me in finding the table (or all tables) referencing one particular sequence.
    Thanks and Regards
    (Please treat this as urgent as i am desperately in need of such a query)

    I share Adrian's scepticism. Using the data dictionary we could find all the program units - TRIGGERS, TYPES, PROCEDURES, etc - which use the sequence. From there we can find all the TABLES that are also referenced by those programs. And that's as good as it gets in Oracle. We cannot definitely say which tables use which sequences (although a good naming convention helps).
    Of course, your DBA may have access to some accurate and up-to-date documentation. But that is maintained externally to the database and not derived from it.
    Cheers, APC

  • Problem while displaying all the table names from a MS Access Data Source.

    I started preparing a small Database application. I want to display all the Table Names which are in the 'MS Access' Data Source.
    I started to executing by "Select * from Tab" as if in SQL.
    But i got an error saying that "Not able to resolve Symbol 'Tab' in the query".
    Please let me know how can i display all the table Names in the MS Access Dats Source.

    Here i am developing the application in Swing using JDBC for accessing the database.
    I want to display all the Table names from the data source in a ListBox for easy selection of tables to view their details.

  • How can I get the table name of my column?

    I'm using the JDK 1.3 trying to get a table name of a column from a result set. Regardless of what driver I'm using (ODBC Bridge/Oracle) I always get a null returned. Does this method work?
    If not, if I'm doing an SQL query that uses more than 1 table and each table has a return of the same column name, how do I distinguish which table the column is from. Thanks

    You can use ResultSetMetaData interface and method
    String getTableName(int column)
    This should return you the table name.
    To get ResultSetMetaData object, you can use
    ResultSetMetaData getMetaData()
    method of ResultSet interface.
    HTH

  • Get the table names from a specified schema name

    Can't any one can hlep me how to use OCIDescribeAny() to retrive the list of table names for a given schema name?
    I have problem when I connect to the database using syste as usr id. I can't ge the table name form the SCOTT schema.

    If I understand you correctly, I don't think OCIDescribeAny() is the way to go.
    You can get a list of tables owned by a particular schema by using the following SQL:-
    SELECT TABLE_NAME FROM DBA_TABLES WHERE OWNER = 'SCOTT'
    Just change the where clause to your needs.
    Regards.
    Adrian

  • How can I get the table name of a field..

    Hi,
    If we know the table name we can find all the fileds from it
    using desc <tablename>.
    But, I would like to find table name of a known field's name.
    Where all these fields are storing in the database.
    THanks in Advance,
    Srinivasulu.

    ALL_TAB_COLUMNS
    rgds, APC

  • How can we get the table name...

    Hi All,
    How can we get the actual table name for an argument if its datatype is %ROWTYPE.
    For Ex :
    function ACCOUNT_UPDATE (account_no number,
    person person%rowtype,
    amounts dbms_describe.number_table,
    trans_date date)
    return accounts.balance%type;
    In the above function 'ACCOUNT_UPDATE', for argument person the datatype is 'person%rowtype'.
    Is there any way to get the name from Data Dictionary tables.
    I tried using All_Arguments and DBMS_DESCRIBE, I can able to get all the individual fields of %ROWTYPE by I could not able to know the exact table name thru the DD.
    my requirement is dynamically I need to declare a variable for the argument datatype.
    Your help is highly appreciated.
    Thanks

    hi vinay,
    this is the easiest way to find the tablename of a particular field.
    t.code:XD01.
    enter.
    select the kunnr field.
    press F1.
    the top of the screen u will get 'Technical setting icon.
    select that one.then u will get tablename,fieldname,parameter id also.
    if helps give the rewards.
    regards,
    akash.k

  • Regarding finding the table name for a field in R12 forms

    Hi all,
    I need to know how to find the table name for a field in R12. I am working on extracting the employee information but i need to know how to get the table names for the fields.
    Thank you,
    raj

    Please see these threads.
    How to find table name in ebs
    How to find table name in ebs
    E-Business tables
    E-Business tables
    Thanks,
    Hussein

  • Were I can get the table of PIKMG

    Dear Guru,
    I want to no from which table I can get the data of Pick Qty.
    When I go to VL02N Pick Qty, their I can find
    Structure : -  LIPSD
    Feild : -  PIKMG.
    But when I am searching in PIKGM I am not getting any data.
    So, will u help me to get the table name of PIKMG.
    Manoj Kumar

    go to tcode: se 11
    enter the name: LIPS (delivery: item data)
    click on display
    you can see the field name: LGMNG (actual qty del in stock keeping units)

  • What is the Table name of Customer Material Info Record.

    Hi Gurus,
    Plz tell me the Table name foe Customer Materiakl Info Recoed which can be reached thru T Code- VD52. Also guide me how to find. I was trying with F1 and further Technical Specifications in it, but unable to get the table name, as i need table name to give for ABAP Specifications.
    Plz help.

    Dear Amit,
    Table Name is KNMT.
    Hope this helps you.
    Do award points if you found them useful.
    Regards,
    Rakesh
    P.S. you can send me a mail at my mail id [email protected] for any specific details

  • How do you get the column names for a given table from an SQL LocalDB programmatically in Visual Basic.

    Just new to this and unable to find answers

    My solution
        Public Function GetTableColumnNames() As Boolean
            Form1.ListBox1.Items.Clear()
            _MDFFileName = String.Format("{0}.mdf", _DatabaseName)
            _sqlConnectionString = String.Format("Data Source=(LocalDB)\v11.0;AttachDBFileName={1};Initial Catalog={0};Integrated Security=True;", _DatabaseName, Path.Combine(_DatabaseDirectory, _MDFFileName))
            Dim cn As New SqlConnection(_sqlConnectionString)
            'put the table name in brackets in case it has spaces in it
            Dim SQLString As String = "SELECT * FROM [" & _TableName & "]"
            Try
                cn.Open()
                Dim cmd As New SqlCommand(SQLString, cn)
                Dim rdr As SqlDataReader =
                cmd.ExecuteReader(CommandBehavior.KeyInfo)
                Dim tbl As DataTable = rdr.GetSchemaTable
                'This shows all of the information you can access about each column.
                For Each col As DataColumn In tbl.Columns
                    Form1.ListBox1.Items.Add(col.ColumnName)
                    Debug.Print("col name = " & col.ColumnName & ", type = " & col.DataType.ToString)
                Next
                'Get each column.
                For Each row As DataRow In tbl.Rows
                    Form1.ListBox1.Items.Add(row("ColumnName"))
                Next
                rdr.Close()
            Catch
                MessageBox.Show("Error opening the connection to the database.")
            Finally
                cn.Close()
            End Try
            Return _Success
        End Function

  • How to get the view name by passing the window name from table

    Hi All,
    would like to knew about the standard table from which we want to "retrieve the VIEW name by passing WINDOW name"
    as we have standard tables like WDY_WINDOW, WDY_VIEW,WDY_APPLICATION but our ZComponent details
    are not updated in this WDY_WINDOW table.
    Is there any other table exists on the above condition
    Regards
    Jaipal.E

    Hello friend,
    There are many structure names started with WDY_WB_VC*where the details of the windows and views are stored just search those structures and see where its getting the tables in run time so that you can get the source tables.
    I think this will be useful for you.
    Thanks,
    Sri Hari

Maybe you are looking for

  • Mac Mail - rebuild address book

    I've replaced the disk drive in my daughter's MacBook after a total disk crash and reinstalled OSX etc. She had quite a lot of stuff backed up, but not her MacMail address book. Fortunately our ISP has kept nearly 3000 emails she sent via webmail (wh

  • Odd fonts in safari

    In some web pages Safari displays an odd non-english font that looks like it could be some sort of eastern european or arabic or something. I assume there's something wrong with the fonts somewhere but I don't know why it would happen in some pages b

  • I want to make a list of my log in names and passwords that are stored in my Firefox profile to give my wife

    Wife and I are old. I am afraid if I die my dear wife won't be able to access any of our joint bank and investment accounts. All I want to do is provide a list for her. I can see the list in the Security window. I highlighted the list, but cannot cop

  • Xml images look pixelated =/

    Hi, I made a site for a friend that uses an xml gallery. If you click the "view portfolio" planet, you will see that the loaded thumbnail images and the full images are pixelly. However, they look fine in the stand-alone swf. I though it might have s

  • Customizing performance threshold for interface utilization in LMS 4.0

    Am running LMS 4.0, i want to customize performance threshold for interface utilization from the default 40% to x%, please help.