1

I am new to Derby, and am trying to determine if the SQL parser in it can be used apart from a real database. For example, I want to be able to get a list of the tables referenced in an SQL statement. I believe this can be done by getting the ContextManager from a given jdbc embedded driver connection, and then getting the result set node from the query tree (see http://rickosborne.org/blog/2010/02/derby-svn-coldfusion-sql-parser/).

The problem I am running into is that the table(s) in the SQL do not actually exist in the Derby DB (and Derby rightfully checks this and responds with a java.sql.SQLSyntaxErrorException: "Table/View 'FOO' does not exist.") So...is there a way to configure the connection so that when one does prepareStatement(sql), the existence of the table isn't checked? (The connection is created using driver.connect("jdbc:derby:memory:dummy;create=true",props) )

1 Answers1

0

Perhaps you could create the tables? Since it's an in-memory database, creating the tables will be a very low-overhead operation.

Bryan Pendleton
  • 16,128
  • 3
  • 32
  • 56
  • Thanks, Bryan. That thought crossed my mind...is Derby going to also throw an exception for each column that does not exist? Is there an easier way to parse an SQL statement and extract the table(s) in it? Derby seems like a strong option, but I don't want to have to create too much of a hack, if possible. – user2183260 Mar 18 '13 at 21:11