Class SignatureChecker

java.lang.Object
org.apache.derby.tools.SignatureChecker

public class SignatureChecker extends Object

This class shows which user declared SQL functions and procedures cannot be matched with Java methods.

To run from the command-line, enter the following if running on J2SE:

java org.apache.derby.tools.SignatureChecker CONNECTION_URL_TO_DATABASE

And enter the following if running on J2ME:

java org.apache.derby.tools.SignatureChecker DATABASE_NAME

  • Field Details

  • Constructor Details

  • Method Details

    • main

      public static void main(String[] args)
    • execute

      private void execute()

      Get a connection to a database and then match the signatures of routines in that database.

    • matchSignatures

      private void matchSignatures(Connection conn) throws SQLException

      Match the signatures of routines in the database attached to this connection.

      Parameters:
      conn - This connection
      Throws:
      SQLException
    • matchProcedures

      private void matchProcedures(Connection conn) throws SQLException

      Match the signatures of procedures in this database.

      Parameters:
      conn - The connection to use to access the database
      Throws:
      SQLException
    • matchFunctions

      private void matchFunctions(Connection conn) throws SQLException

      Match the signatures of functions in this database.

      Parameters:
      conn - The connection to use to access the database
      Throws:
      SQLException
    • makeReadableSignature

      private String makeReadableSignature(SignatureChecker.SQLRoutine routine)

      Make a human readable signature for a routine. This can be used in error messages.

      Parameters:
      routine - the routine for which we want a signature
      Returns:
      human readable string
    • findProcedures

      private void findProcedures(DatabaseMetaData dbmd) throws SQLException

      Find all of the user-declared procedures.

      Parameters:
      dbmd - the database metadata of the database
      Throws:
      SQLException
    • countProcedureArgs

      private void countProcedureArgs(DatabaseMetaData dbmd) throws SQLException

      Count up the arguments to the user-coded procedures in _procedures and update that data structure accordingly

      Parameters:
      dbmd - the database metadata of the database
      Throws:
      SQLException
    • findFunctions

      private void findFunctions(DatabaseMetaData dbmd) throws SQLException

      Find all of the user-declared functions. We use reflection to get our hands on getFunctions() because that method does not appear in the JSR169 api for DatabaseMetaData. Update _functions.

      Parameters:
      dbmd - the database metadata of the database
      Throws:
      SQLException
    • countFunctionArgs

      private void countFunctionArgs(DatabaseMetaData dbmd) throws SQLException

      Count up the arguments to the user-coded procedures. We use reflection to look up the getFunctionColumns() method because that method does not appear in the JSR169 api for DatabaseMetaData. Update _functions.

      Parameters:
      dbmd - the database metadata of the database
      Throws:
      SQLException
    • checkSignature

      private void checkSignature(Connection conn, String query, String readableSignature)

      Prepared a routine invocation in order to check whether it matches a Java method.

      Parameters:
      conn - The connection to the database
      query - The SQL to prepare
      readableSignature - the signature: printed if prepare fails
    • getJ2SEConnection

      private Connection getJ2SEConnection() throws SQLException
      We use reflection to get the J2SE connection so that references to DriverManager will not generate linkage errors on old J2ME platforms which may resolve references eagerly.
      Returns:
      a connection to the database
      Throws:
      SQLException
    • prepareStatement

      private PreparedStatement prepareStatement(Connection conn, String text) throws SQLException
      Throws:
      SQLException
    • printUsage

      private static void printUsage()
    • printThrowable

      private static void printThrowable(Throwable t)
    • println

      private static void println(String text)
    • isSystemSchema

      private boolean isSystemSchema(String schema)
      Return true if the schema is a system schema.
      Parameters:
      schema - the schema to check
      Returns:
      true if the schema is a system schema
    • putProcedure

      private void putProcedure(String schema, String name)
      Store a procedure descriptor. Updates _procedures.
      Parameters:
      schema - schema of the procedure
      name - of a procedure
    • getProcedure

      private SignatureChecker.SQLRoutine getProcedure(int idx)
      Get a procedure descriptor from _procedures.
      Parameters:
      idx - The index of the procedure in _procedures.
      Returns:
      a procedure descriptor
    • putFunction

      private void putFunction(String schema, String name, boolean isTableFunction)
      Store a function descriptor. Updates _functions.
      Parameters:
      schema - The schema of the function
      name - The name of the function
      isTableFunction - true iff the function is a table function
    • getFunction

      private SignatureChecker.SQLRoutine getFunction(int idx)
      Get a function descriptor from _functions .
      Parameters:
      idx - The index of the procedure in _functions.
      Returns:
      a function descriptor
    • formatMessage

      private static String formatMessage(String key, Object... args)
      Format a localizable message.
      Parameters:
      key - The message key by which we located the localized text
      args - Any arguments to the localized text to be filled in
      Returns:
      A localized message
    • getMessageFormatter

      private static LocalizedResource getMessageFormatter()
      Get the message resource.
      Returns:
      localized resource