Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6575027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:20:12+00:00 2026-05-25T15:20:12+00:00

I need to enumerate the tables in a Derby (aka Java DB) database using

  • 0

I need to enumerate the tables in a Derby (aka Java DB) database using JDBC in a Java program. All I am aware of for doing this is the SHOW TABLES command.

I first tried with something similar to this…

String strConnectionURL = "jdbc:derby:/path/to/derby/database;create=false";
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
Connection connection = DriverManager.getConnection(strConnectionURL);
Statement statement = connection.createStatement();
boolean boResult = statement.execute("SHOW TABLES");
if (boResult) {
    System.out.println("yay!");
}

…but that throws an exception:

java.sql.SQLSyntaxErrorException: Syntax error: Encountered "SHOW" at line 1, column 1.

So next I thought maybe I needed to use a CallableStatement so I tried this…

String strConnectionURL = "jdbc:derby:/path/to/derby/db;create=false";
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
Connection connection = DriverManager.getConnection(strConnectionURL);
CallableStatement statement = connection.prepareCall("SHOW TABLES");
boolean boResult = statement.execute();
if (boResult) {
    System.out.println("yippee!");
}

…but that throws the same exception:

java.sql.SQLSyntaxErrorException: Syntax error: Encountered "SHOW" at line 1, column 1.

So, can anyone help me enumerate the tables in my Derby (Java DB) database from JDBC?

EDIT: I’m looking around and starting to get a feeling this may be a general JDBC question. In other words, one could/would enumerate all a db’s tables with the DatabaseMetaData object that can be retrieved from the Connection object. Looking into that (and looking forward to responses)…

EDIT 2: I found a pure JDBC solution, but am still happy to hear alternatives…

String strConnectionURL = "jdbc:derby:/path/to/db;create=false";
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
Connection connection = DriverManager.getConnection(strConnectionURL);
DatabaseMetaData dbmd = connection.getMetaData();
ResultSet resultSet = dbmd.getTables(null, null, null, null);
while (resultSet.next()) {
    String strTableName = resultSet.getString("TABLE_NAME");
    System.out.println("TABLE_NAME is " + strTableName);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:20:13+00:00Added an answer on May 25, 2026 at 3:20 pm

    Show Tables is an ij command, not a base SQL statement, so you can’t directly execute it. As you noted in your “EDIT 2”, you can use the DatabaseMetaData to do this. Two other ways to do it are: you can select from the system catalogs (see http://db.apache.org/derby/docs/10.8/ref/rrefsistabs24269.html) , or you can use the “ij.runScript” method to run the ij tool from within your program, and pass it the “show tables” command (see http://db.apache.org/derby/docs/10.8/publishedapi/jdbc3/org/apache/derby/tools/ij.html)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to enumerate SQL Servers from a VB.Net program. This fails if the
I need to enumerate all the user defined types created in a SQL Server
Using LaTeX , I need to show some code snippet inside a table. Here
I need to enumerate all classes in a package and add them to a
I need to enumerate all open windows and get their title, but the problem
Hello guys i'm making a little app in which i need to enumerate all
Using Visual Studio 2010 How can I enumerate all resources within in a specific
I need to find a way to enumerate all my iPhone application's active threads.
I need to enumerate though generic IList<> of objects. The contents of the list
For GUI purposes I need by current state of state machine to enumerate possible

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.