privileges oracle jdbc getMetaData












0















I'm using the JDBC Driver to connect to different database type.
My database's users have only view permissions on the Catalog.
It works fine for hive/teradata but not with Oracle.



With Oracle, I'm able to retrieve Schemas but not Tables/Columns.



Oracle privileges :




SELECT_CATALOG_ROLE, CREATE SESSION, CONNECT




Java Code :




DatabaseMetaData databaseMetadata = con.getMetaData();
resTables = databaseMetadata.getTables("Test_Schema", null, null,
null);




But once I give select permission on tables, it works.



Do I miss something ?










share|improve this question























  • what version are you using of JDBC driver? It just queries all_objects o, all_tab_comments so select catalog should work in 18.3 at least.

    – Kris Rice
    Nov 21 '18 at 12:49






  • 1





    Hi Kris, all_objets does not contain other users tables

    – nbsr
    Nov 21 '18 at 13:00











  • The all in all_objets is for all users respecting what's granted. user_objects is the current schema only.

    – Kris Rice
    Nov 21 '18 at 13:02











  • Thanks Kris, is it possible to grant access to metadata without granting access to data ?

    – nbsr
    Nov 21 '18 at 13:54











  • Yes. Perform the sql

    – Kris Rice
    Nov 21 '18 at 13:55
















0















I'm using the JDBC Driver to connect to different database type.
My database's users have only view permissions on the Catalog.
It works fine for hive/teradata but not with Oracle.



With Oracle, I'm able to retrieve Schemas but not Tables/Columns.



Oracle privileges :




SELECT_CATALOG_ROLE, CREATE SESSION, CONNECT




Java Code :




DatabaseMetaData databaseMetadata = con.getMetaData();
resTables = databaseMetadata.getTables("Test_Schema", null, null,
null);




But once I give select permission on tables, it works.



Do I miss something ?










share|improve this question























  • what version are you using of JDBC driver? It just queries all_objects o, all_tab_comments so select catalog should work in 18.3 at least.

    – Kris Rice
    Nov 21 '18 at 12:49






  • 1





    Hi Kris, all_objets does not contain other users tables

    – nbsr
    Nov 21 '18 at 13:00











  • The all in all_objets is for all users respecting what's granted. user_objects is the current schema only.

    – Kris Rice
    Nov 21 '18 at 13:02











  • Thanks Kris, is it possible to grant access to metadata without granting access to data ?

    – nbsr
    Nov 21 '18 at 13:54











  • Yes. Perform the sql

    – Kris Rice
    Nov 21 '18 at 13:55














0












0








0








I'm using the JDBC Driver to connect to different database type.
My database's users have only view permissions on the Catalog.
It works fine for hive/teradata but not with Oracle.



With Oracle, I'm able to retrieve Schemas but not Tables/Columns.



Oracle privileges :




SELECT_CATALOG_ROLE, CREATE SESSION, CONNECT




Java Code :




DatabaseMetaData databaseMetadata = con.getMetaData();
resTables = databaseMetadata.getTables("Test_Schema", null, null,
null);




But once I give select permission on tables, it works.



Do I miss something ?










share|improve this question














I'm using the JDBC Driver to connect to different database type.
My database's users have only view permissions on the Catalog.
It works fine for hive/teradata but not with Oracle.



With Oracle, I'm able to retrieve Schemas but not Tables/Columns.



Oracle privileges :




SELECT_CATALOG_ROLE, CREATE SESSION, CONNECT




Java Code :




DatabaseMetaData databaseMetadata = con.getMetaData();
resTables = databaseMetadata.getTables("Test_Schema", null, null,
null);




But once I give select permission on tables, it works.



Do I miss something ?







java oracle






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 11:06









nbsrnbsr

1




1













  • what version are you using of JDBC driver? It just queries all_objects o, all_tab_comments so select catalog should work in 18.3 at least.

    – Kris Rice
    Nov 21 '18 at 12:49






  • 1





    Hi Kris, all_objets does not contain other users tables

    – nbsr
    Nov 21 '18 at 13:00











  • The all in all_objets is for all users respecting what's granted. user_objects is the current schema only.

    – Kris Rice
    Nov 21 '18 at 13:02











  • Thanks Kris, is it possible to grant access to metadata without granting access to data ?

    – nbsr
    Nov 21 '18 at 13:54











  • Yes. Perform the sql

    – Kris Rice
    Nov 21 '18 at 13:55



















  • what version are you using of JDBC driver? It just queries all_objects o, all_tab_comments so select catalog should work in 18.3 at least.

    – Kris Rice
    Nov 21 '18 at 12:49






  • 1





    Hi Kris, all_objets does not contain other users tables

    – nbsr
    Nov 21 '18 at 13:00











  • The all in all_objets is for all users respecting what's granted. user_objects is the current schema only.

    – Kris Rice
    Nov 21 '18 at 13:02











  • Thanks Kris, is it possible to grant access to metadata without granting access to data ?

    – nbsr
    Nov 21 '18 at 13:54











  • Yes. Perform the sql

    – Kris Rice
    Nov 21 '18 at 13:55

















what version are you using of JDBC driver? It just queries all_objects o, all_tab_comments so select catalog should work in 18.3 at least.

– Kris Rice
Nov 21 '18 at 12:49





what version are you using of JDBC driver? It just queries all_objects o, all_tab_comments so select catalog should work in 18.3 at least.

– Kris Rice
Nov 21 '18 at 12:49




1




1





Hi Kris, all_objets does not contain other users tables

– nbsr
Nov 21 '18 at 13:00





Hi Kris, all_objets does not contain other users tables

– nbsr
Nov 21 '18 at 13:00













The all in all_objets is for all users respecting what's granted. user_objects is the current schema only.

– Kris Rice
Nov 21 '18 at 13:02





The all in all_objets is for all users respecting what's granted. user_objects is the current schema only.

– Kris Rice
Nov 21 '18 at 13:02













Thanks Kris, is it possible to grant access to metadata without granting access to data ?

– nbsr
Nov 21 '18 at 13:54





Thanks Kris, is it possible to grant access to metadata without granting access to data ?

– nbsr
Nov 21 '18 at 13:54













Yes. Perform the sql

– Kris Rice
Nov 21 '18 at 13:55





Yes. Perform the sql

– Kris Rice
Nov 21 '18 at 13:55












2 Answers
2






active

oldest

votes


















0














SELECT_CATALOG_ROLE allow SELECT privileges on data dictionary views(for exapmle select * from dba_users)
, but not for user tables.
You must explicitly specify the rights to the desired table for example
grant select,update,delete on need_table for user_name;
grant select,update,delete on DEPARTMENTS to test;



or give select right to all tables (bad practic).



[oracle10@aktp ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Wed Nov 21 14:39:55 2018

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> grant select any table to test;

Grant succeeded.


.






share|improve this answer
























  • Hi Dmitry, Thanks. Does it mean that it is not possible to give access to dba_users metadata whithout giving access to their data ?

    – nbsr
    Nov 21 '18 at 11:51



















0














Using DatabaseMetaData.getMetaData replies on the underlying views all_objects , all_tab_comments, and all_synonyms. These views take into consideration what is granted for access.



SELECT_CATALOG_ROLE grants access to the catalog which would allow to query dba_objects.



To do what is asked, a mirrored Java API to DatabaseMetaData.getMetaData().getTables(..) can be easily written to use dba_xyz views. Something along the lines of this.



import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;

import oracle.jdbc.OracleConnection;
import oracle.jdbc.OracleDatabaseMetaData;

public class MyMetaData extends OracleDatabaseMetaData {



public MyMetaData(Connection conn) {
super((OracleConnection) conn);
}

public synchronized ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String types) throws SQLException {
// catalog isn't used
// dba view based sql

String sql = "SELECT NULL AS table_cat,"+
" o.owner AS table_schem,n "+
" o.object_name AS table_name,n "+
" o.object_type AS table_type,n"+
" c.comments AS remarksn" +
" FROM dba_objects o, dba_tab_comments cn"+
" WHERE o.owner LIKE :1 ESCAPE '/'n "+
" AND o.object_name LIKE :2 ESCAPE '/'n"+
" AND o.owner = c.owner (+)n "+
" AND o.object_name = c.table_name (+)n";

// bind params

PreparedStatement stmt = connection.prepareStatement(sql);
stmt.setString(1, schemaPattern == null ? "%" : schemaPattern);
stmt.setString(2, tableNamePattern == null ? "%" : tableNamePattern);

return stmt.executeQuery();
}

public static void main(String args) throws SQLException {

String conString = "jdbc:oracle:thin:@//localhost:1521/xe";
Properties props = new Properties();
props.setProperty("user", "klrice");
props.setProperty("password", "klrice");
Connection conn = DriverManager.getConnection(conString, props);
// use this class
MyMetaData md = new MyMetaData(conn);

// test it out
ResultSet rset = md.getTables(null, "ORDS_METADATA", null, null);
while (rset.next()) {
System.out.println(rset.getString(2));
}

}

}





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410772%2fprivileges-oracle-jdbc-getmetadata%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    SELECT_CATALOG_ROLE allow SELECT privileges on data dictionary views(for exapmle select * from dba_users)
    , but not for user tables.
    You must explicitly specify the rights to the desired table for example
    grant select,update,delete on need_table for user_name;
    grant select,update,delete on DEPARTMENTS to test;



    or give select right to all tables (bad practic).



    [oracle10@aktp ~]$ sqlplus / as sysdba

    SQL*Plus: Release 10.2.0.4.0 - Production on Wed Nov 21 14:39:55 2018

    Copyright (c) 1982, 2007, Oracle. All Rights Reserved.


    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options

    SQL> grant select any table to test;

    Grant succeeded.


    .






    share|improve this answer
























    • Hi Dmitry, Thanks. Does it mean that it is not possible to give access to dba_users metadata whithout giving access to their data ?

      – nbsr
      Nov 21 '18 at 11:51
















    0














    SELECT_CATALOG_ROLE allow SELECT privileges on data dictionary views(for exapmle select * from dba_users)
    , but not for user tables.
    You must explicitly specify the rights to the desired table for example
    grant select,update,delete on need_table for user_name;
    grant select,update,delete on DEPARTMENTS to test;



    or give select right to all tables (bad practic).



    [oracle10@aktp ~]$ sqlplus / as sysdba

    SQL*Plus: Release 10.2.0.4.0 - Production on Wed Nov 21 14:39:55 2018

    Copyright (c) 1982, 2007, Oracle. All Rights Reserved.


    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options

    SQL> grant select any table to test;

    Grant succeeded.


    .






    share|improve this answer
























    • Hi Dmitry, Thanks. Does it mean that it is not possible to give access to dba_users metadata whithout giving access to their data ?

      – nbsr
      Nov 21 '18 at 11:51














    0












    0








    0







    SELECT_CATALOG_ROLE allow SELECT privileges on data dictionary views(for exapmle select * from dba_users)
    , but not for user tables.
    You must explicitly specify the rights to the desired table for example
    grant select,update,delete on need_table for user_name;
    grant select,update,delete on DEPARTMENTS to test;



    or give select right to all tables (bad practic).



    [oracle10@aktp ~]$ sqlplus / as sysdba

    SQL*Plus: Release 10.2.0.4.0 - Production on Wed Nov 21 14:39:55 2018

    Copyright (c) 1982, 2007, Oracle. All Rights Reserved.


    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options

    SQL> grant select any table to test;

    Grant succeeded.


    .






    share|improve this answer













    SELECT_CATALOG_ROLE allow SELECT privileges on data dictionary views(for exapmle select * from dba_users)
    , but not for user tables.
    You must explicitly specify the rights to the desired table for example
    grant select,update,delete on need_table for user_name;
    grant select,update,delete on DEPARTMENTS to test;



    or give select right to all tables (bad practic).



    [oracle10@aktp ~]$ sqlplus / as sysdba

    SQL*Plus: Release 10.2.0.4.0 - Production on Wed Nov 21 14:39:55 2018

    Copyright (c) 1982, 2007, Oracle. All Rights Reserved.


    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options

    SQL> grant select any table to test;

    Grant succeeded.


    .







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 21 '18 at 11:42









    Dmitry DeminDmitry Demin

    1,0251410




    1,0251410













    • Hi Dmitry, Thanks. Does it mean that it is not possible to give access to dba_users metadata whithout giving access to their data ?

      – nbsr
      Nov 21 '18 at 11:51



















    • Hi Dmitry, Thanks. Does it mean that it is not possible to give access to dba_users metadata whithout giving access to their data ?

      – nbsr
      Nov 21 '18 at 11:51

















    Hi Dmitry, Thanks. Does it mean that it is not possible to give access to dba_users metadata whithout giving access to their data ?

    – nbsr
    Nov 21 '18 at 11:51





    Hi Dmitry, Thanks. Does it mean that it is not possible to give access to dba_users metadata whithout giving access to their data ?

    – nbsr
    Nov 21 '18 at 11:51













    0














    Using DatabaseMetaData.getMetaData replies on the underlying views all_objects , all_tab_comments, and all_synonyms. These views take into consideration what is granted for access.



    SELECT_CATALOG_ROLE grants access to the catalog which would allow to query dba_objects.



    To do what is asked, a mirrored Java API to DatabaseMetaData.getMetaData().getTables(..) can be easily written to use dba_xyz views. Something along the lines of this.



    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.Properties;

    import oracle.jdbc.OracleConnection;
    import oracle.jdbc.OracleDatabaseMetaData;

    public class MyMetaData extends OracleDatabaseMetaData {



    public MyMetaData(Connection conn) {
    super((OracleConnection) conn);
    }

    public synchronized ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String types) throws SQLException {
    // catalog isn't used
    // dba view based sql

    String sql = "SELECT NULL AS table_cat,"+
    " o.owner AS table_schem,n "+
    " o.object_name AS table_name,n "+
    " o.object_type AS table_type,n"+
    " c.comments AS remarksn" +
    " FROM dba_objects o, dba_tab_comments cn"+
    " WHERE o.owner LIKE :1 ESCAPE '/'n "+
    " AND o.object_name LIKE :2 ESCAPE '/'n"+
    " AND o.owner = c.owner (+)n "+
    " AND o.object_name = c.table_name (+)n";

    // bind params

    PreparedStatement stmt = connection.prepareStatement(sql);
    stmt.setString(1, schemaPattern == null ? "%" : schemaPattern);
    stmt.setString(2, tableNamePattern == null ? "%" : tableNamePattern);

    return stmt.executeQuery();
    }

    public static void main(String args) throws SQLException {

    String conString = "jdbc:oracle:thin:@//localhost:1521/xe";
    Properties props = new Properties();
    props.setProperty("user", "klrice");
    props.setProperty("password", "klrice");
    Connection conn = DriverManager.getConnection(conString, props);
    // use this class
    MyMetaData md = new MyMetaData(conn);

    // test it out
    ResultSet rset = md.getTables(null, "ORDS_METADATA", null, null);
    while (rset.next()) {
    System.out.println(rset.getString(2));
    }

    }

    }





    share|improve this answer




























      0














      Using DatabaseMetaData.getMetaData replies on the underlying views all_objects , all_tab_comments, and all_synonyms. These views take into consideration what is granted for access.



      SELECT_CATALOG_ROLE grants access to the catalog which would allow to query dba_objects.



      To do what is asked, a mirrored Java API to DatabaseMetaData.getMetaData().getTables(..) can be easily written to use dba_xyz views. Something along the lines of this.



      import java.sql.Connection;
      import java.sql.DriverManager;
      import java.sql.PreparedStatement;
      import java.sql.ResultSet;
      import java.sql.SQLException;
      import java.util.Properties;

      import oracle.jdbc.OracleConnection;
      import oracle.jdbc.OracleDatabaseMetaData;

      public class MyMetaData extends OracleDatabaseMetaData {



      public MyMetaData(Connection conn) {
      super((OracleConnection) conn);
      }

      public synchronized ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String types) throws SQLException {
      // catalog isn't used
      // dba view based sql

      String sql = "SELECT NULL AS table_cat,"+
      " o.owner AS table_schem,n "+
      " o.object_name AS table_name,n "+
      " o.object_type AS table_type,n"+
      " c.comments AS remarksn" +
      " FROM dba_objects o, dba_tab_comments cn"+
      " WHERE o.owner LIKE :1 ESCAPE '/'n "+
      " AND o.object_name LIKE :2 ESCAPE '/'n"+
      " AND o.owner = c.owner (+)n "+
      " AND o.object_name = c.table_name (+)n";

      // bind params

      PreparedStatement stmt = connection.prepareStatement(sql);
      stmt.setString(1, schemaPattern == null ? "%" : schemaPattern);
      stmt.setString(2, tableNamePattern == null ? "%" : tableNamePattern);

      return stmt.executeQuery();
      }

      public static void main(String args) throws SQLException {

      String conString = "jdbc:oracle:thin:@//localhost:1521/xe";
      Properties props = new Properties();
      props.setProperty("user", "klrice");
      props.setProperty("password", "klrice");
      Connection conn = DriverManager.getConnection(conString, props);
      // use this class
      MyMetaData md = new MyMetaData(conn);

      // test it out
      ResultSet rset = md.getTables(null, "ORDS_METADATA", null, null);
      while (rset.next()) {
      System.out.println(rset.getString(2));
      }

      }

      }





      share|improve this answer


























        0












        0








        0







        Using DatabaseMetaData.getMetaData replies on the underlying views all_objects , all_tab_comments, and all_synonyms. These views take into consideration what is granted for access.



        SELECT_CATALOG_ROLE grants access to the catalog which would allow to query dba_objects.



        To do what is asked, a mirrored Java API to DatabaseMetaData.getMetaData().getTables(..) can be easily written to use dba_xyz views. Something along the lines of this.



        import java.sql.Connection;
        import java.sql.DriverManager;
        import java.sql.PreparedStatement;
        import java.sql.ResultSet;
        import java.sql.SQLException;
        import java.util.Properties;

        import oracle.jdbc.OracleConnection;
        import oracle.jdbc.OracleDatabaseMetaData;

        public class MyMetaData extends OracleDatabaseMetaData {



        public MyMetaData(Connection conn) {
        super((OracleConnection) conn);
        }

        public synchronized ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String types) throws SQLException {
        // catalog isn't used
        // dba view based sql

        String sql = "SELECT NULL AS table_cat,"+
        " o.owner AS table_schem,n "+
        " o.object_name AS table_name,n "+
        " o.object_type AS table_type,n"+
        " c.comments AS remarksn" +
        " FROM dba_objects o, dba_tab_comments cn"+
        " WHERE o.owner LIKE :1 ESCAPE '/'n "+
        " AND o.object_name LIKE :2 ESCAPE '/'n"+
        " AND o.owner = c.owner (+)n "+
        " AND o.object_name = c.table_name (+)n";

        // bind params

        PreparedStatement stmt = connection.prepareStatement(sql);
        stmt.setString(1, schemaPattern == null ? "%" : schemaPattern);
        stmt.setString(2, tableNamePattern == null ? "%" : tableNamePattern);

        return stmt.executeQuery();
        }

        public static void main(String args) throws SQLException {

        String conString = "jdbc:oracle:thin:@//localhost:1521/xe";
        Properties props = new Properties();
        props.setProperty("user", "klrice");
        props.setProperty("password", "klrice");
        Connection conn = DriverManager.getConnection(conString, props);
        // use this class
        MyMetaData md = new MyMetaData(conn);

        // test it out
        ResultSet rset = md.getTables(null, "ORDS_METADATA", null, null);
        while (rset.next()) {
        System.out.println(rset.getString(2));
        }

        }

        }





        share|improve this answer













        Using DatabaseMetaData.getMetaData replies on the underlying views all_objects , all_tab_comments, and all_synonyms. These views take into consideration what is granted for access.



        SELECT_CATALOG_ROLE grants access to the catalog which would allow to query dba_objects.



        To do what is asked, a mirrored Java API to DatabaseMetaData.getMetaData().getTables(..) can be easily written to use dba_xyz views. Something along the lines of this.



        import java.sql.Connection;
        import java.sql.DriverManager;
        import java.sql.PreparedStatement;
        import java.sql.ResultSet;
        import java.sql.SQLException;
        import java.util.Properties;

        import oracle.jdbc.OracleConnection;
        import oracle.jdbc.OracleDatabaseMetaData;

        public class MyMetaData extends OracleDatabaseMetaData {



        public MyMetaData(Connection conn) {
        super((OracleConnection) conn);
        }

        public synchronized ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String types) throws SQLException {
        // catalog isn't used
        // dba view based sql

        String sql = "SELECT NULL AS table_cat,"+
        " o.owner AS table_schem,n "+
        " o.object_name AS table_name,n "+
        " o.object_type AS table_type,n"+
        " c.comments AS remarksn" +
        " FROM dba_objects o, dba_tab_comments cn"+
        " WHERE o.owner LIKE :1 ESCAPE '/'n "+
        " AND o.object_name LIKE :2 ESCAPE '/'n"+
        " AND o.owner = c.owner (+)n "+
        " AND o.object_name = c.table_name (+)n";

        // bind params

        PreparedStatement stmt = connection.prepareStatement(sql);
        stmt.setString(1, schemaPattern == null ? "%" : schemaPattern);
        stmt.setString(2, tableNamePattern == null ? "%" : tableNamePattern);

        return stmt.executeQuery();
        }

        public static void main(String args) throws SQLException {

        String conString = "jdbc:oracle:thin:@//localhost:1521/xe";
        Properties props = new Properties();
        props.setProperty("user", "klrice");
        props.setProperty("password", "klrice");
        Connection conn = DriverManager.getConnection(conString, props);
        // use this class
        MyMetaData md = new MyMetaData(conn);

        // test it out
        ResultSet rset = md.getTables(null, "ORDS_METADATA", null, null);
        while (rset.next()) {
        System.out.println(rset.getString(2));
        }

        }

        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '18 at 21:48









        Kris RiceKris Rice

        2,371728




        2,371728






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410772%2fprivileges-oracle-jdbc-getmetadata%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to send String Array data to Server using php in android

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

            Is anime1.com a legal site for watching anime?