org.apache.derby.tools
Class SignatureChecker

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

public class SignatureChecker
extends java.lang.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


Nested Class Summary
(package private) static class SignatureChecker.ParsedArgs
           
(package private)  class SignatureChecker.SQLRoutine
           
 
Field Summary
private  boolean _debugging
           
private  java.util.ArrayList _functions
           
private static LocalizedResource _messageFormatter
           
private  SignatureChecker.ParsedArgs _parsedArgs
           
private  java.util.ArrayList _procedures
           
private static java.lang.String[] SYSTEM_SCHEMAS
           
private static java.lang.String WILDCARD
           
 
Constructor Summary
private SignatureChecker(SignatureChecker.ParsedArgs parsedArgs)
           
 
Method Summary
private  void checkSignature(java.sql.Connection conn, SignatureChecker.SQLRoutine routine, java.lang.String query, java.lang.String readableSignature)
           Prepared a routine invocation in order to check whether it matches a Java method.
private  void countFunctionArgs(java.sql.DatabaseMetaData dbmd)
           Count up the arguments to the user-coded procedures.
private  void countProcedureArgs(java.sql.DatabaseMetaData dbmd)
           Count up the arguments to the user-coded procedures.
private  void execute()
           Get a connection to a database and then match the signatures of routines in that database.
private  void findFunctions(java.sql.DatabaseMetaData dbmd)
           Find all of the user-declared functions.
private  void findProcedures(java.sql.DatabaseMetaData dbmd)
           Find all of the user-declared procedures.
private static java.lang.String formatMessage(java.lang.String key)
          Format a localizable message with 0 args.
private static java.lang.String formatMessage(java.lang.String key, java.lang.String arg0)
          Format a localizable message with 1 arg.
private static java.lang.String formatMessage(java.lang.String key, java.lang.String arg0, java.lang.String arg1)
          Format a localizable message with 2 args.
private  SignatureChecker.SQLRoutine getFunction(int idx)
          Get a functon descriptor.
private  java.sql.Connection getJ2MEConnection()
           
private  java.sql.Connection getJ2SEConnection()
          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.
private static LocalizedResource getMessageFormatter()
          Get the message resource.
private  SignatureChecker.SQLRoutine getProcedure(int idx)
          Get a procedure descriptor.
private  boolean isSystemSchema(java.lang.String schema)
          Return true if the schema is a system schema.
static void main(java.lang.String[] args)
           
private  java.lang.String makeReadableSignature(SignatureChecker.SQLRoutine routine)
           Make a human readable signature for a routine.
private  void matchFunctions(java.sql.Connection conn)
           Match the signatures of functions in this database.
private  void matchProcedures(java.sql.Connection conn)
           Match the signatures of procedures in this database.
private  void matchSignatures(java.sql.Connection conn)
           Match the signatures of routines in the database attached to this connection.
private  java.sql.PreparedStatement prepareStatement(java.sql.Connection conn, java.lang.String text)
           
private static void println(java.lang.String text)
           
private static void printThrowable(java.lang.Throwable t)
           
private static void printUsage()
           
private  void putFunction(java.lang.String schema, java.lang.String name, boolean isTableFunction)
          Store a function descriptor.
private  void putProcedure(java.lang.String schema, java.lang.String name)
          Store a procedure descriptor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WILDCARD

private static final java.lang.String WILDCARD
See Also:
Constant Field Values

SYSTEM_SCHEMAS

private static final java.lang.String[] SYSTEM_SCHEMAS

_parsedArgs

private SignatureChecker.ParsedArgs _parsedArgs

_procedures

private java.util.ArrayList _procedures

_functions

private java.util.ArrayList _functions

_debugging

private boolean _debugging

_messageFormatter

private static LocalizedResource _messageFormatter
Constructor Detail

SignatureChecker

private SignatureChecker(SignatureChecker.ParsedArgs parsedArgs)
Method Detail

main

public static void main(java.lang.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(java.sql.Connection conn)
                      throws java.sql.SQLException

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

Throws:
java.sql.SQLException

matchProcedures

private void matchProcedures(java.sql.Connection conn)
                      throws java.sql.SQLException

Match the signatures of procedures in this database.

Throws:
java.sql.SQLException

matchFunctions

private void matchFunctions(java.sql.Connection conn)
                     throws java.sql.SQLException

Match the signatures of functions in this database.

Throws:
java.sql.SQLException

makeReadableSignature

private java.lang.String makeReadableSignature(SignatureChecker.SQLRoutine routine)

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


findProcedures

private void findProcedures(java.sql.DatabaseMetaData dbmd)
                     throws java.sql.SQLException

Find all of the user-declared procedures.

Throws:
java.sql.SQLException

countProcedureArgs

private void countProcedureArgs(java.sql.DatabaseMetaData dbmd)
                         throws java.sql.SQLException

Count up the arguments to the user-coded procedures.

Throws:
java.sql.SQLException

findFunctions

private void findFunctions(java.sql.DatabaseMetaData dbmd)
                    throws java.sql.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.

Throws:
java.sql.SQLException

countFunctionArgs

private void countFunctionArgs(java.sql.DatabaseMetaData dbmd)
                        throws java.sql.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.

Throws:
java.sql.SQLException

checkSignature

private void checkSignature(java.sql.Connection conn,
                            SignatureChecker.SQLRoutine routine,
                            java.lang.String query,
                            java.lang.String readableSignature)

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


getJ2MEConnection

private java.sql.Connection getJ2MEConnection()
                                       throws java.sql.SQLException
Throws:
java.sql.SQLException

getJ2SEConnection

private java.sql.Connection getJ2SEConnection()
                                       throws java.sql.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.

Throws:
java.sql.SQLException

prepareStatement

private java.sql.PreparedStatement prepareStatement(java.sql.Connection conn,
                                                    java.lang.String text)
                                             throws java.sql.SQLException
Throws:
java.sql.SQLException

printUsage

private static void printUsage()

printThrowable

private static void printThrowable(java.lang.Throwable t)

println

private static void println(java.lang.String text)

isSystemSchema

private boolean isSystemSchema(java.lang.String schema)
Return true if the schema is a system schema.


putProcedure

private void putProcedure(java.lang.String schema,
                          java.lang.String name)
Store a procedure descriptor.


getProcedure

private SignatureChecker.SQLRoutine getProcedure(int idx)
Get a procedure descriptor.


putFunction

private void putFunction(java.lang.String schema,
                         java.lang.String name,
                         boolean isTableFunction)
Store a function descriptor.


getFunction

private SignatureChecker.SQLRoutine getFunction(int idx)
Get a functon descriptor.


formatMessage

private static java.lang.String formatMessage(java.lang.String key)
Format a localizable message with 0 args.


formatMessage

private static java.lang.String formatMessage(java.lang.String key,
                                              java.lang.String arg0)
Format a localizable message with 1 arg.


formatMessage

private static java.lang.String formatMessage(java.lang.String key,
                                              java.lang.String arg0,
                                              java.lang.String arg1)
Format a localizable message with 2 args.


getMessageFormatter

private static LocalizedResource getMessageFormatter()
Get the message resource.


Built on Thu 2012-03-29 21:53:33+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.