Class SignatureChecker
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
Nested ClassesModifier and TypeClassDescription(package private) static class////////////////////////////////////////////////////////////////////////////////(package private) class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate final ArrayList<SignatureChecker.SQLRoutine> private static LocalizedResourceprivate final SignatureChecker.ParsedArgs////////////////////////////////////////////////////////////////////////////////private final ArrayList<SignatureChecker.SQLRoutine> private static final String[]private static final String//////////////////////////////////////////////////////////////////////////////// -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateSignatureChecker(SignatureChecker.ParsedArgs parsedArgs) //////////////////////////////////////////////////////////////////////////////// -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckSignature(Connection conn, String query, String readableSignature) Prepared a routine invocation in order to check whether it matches a Java method.private voidCount up the arguments to the user-coded procedures.private voidCount up the arguments to the user-coded procedures in_proceduresand update that data structure accordinglyprivate voidexecute()Get a connection to a database and then match the signatures of routines in that database.private voidFind all of the user-declared functions.private voidFind all of the user-declared procedures.private static StringformatMessage(String key, Object... args) Format a localizable message.private SignatureChecker.SQLRoutinegetFunction(int idx) Get a function descriptor from_functions.private ConnectionWe 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 LocalizedResourceGet the message resource.private SignatureChecker.SQLRoutinegetProcedure(int idx) Get a procedure descriptor from_procedures.private booleanisSystemSchema(String schema) Return true if the schema is a system schema.static void////////////////////////////////////////////////////////////////////////////////private StringMake a human readable signature for a routine.private voidmatchFunctions(Connection conn) Match the signatures of functions in this database.private voidmatchProcedures(Connection conn) Match the signatures of procedures in this database.private voidmatchSignatures(Connection conn) Match the signatures of routines in the database attached to this connection.private PreparedStatementprepareStatement(Connection conn, String text) private static voidprivate static voidprivate static voidprivate voidputFunction(String schema, String name, boolean isTableFunction) Store a function descriptor.private voidputProcedure(String schema, String name) Store a procedure descriptor.
-
Field Details
-
WILDCARD
////////////////////////////////////////////////////////////////////////////////- See Also:
-
SYSTEM_SCHEMAS
-
_parsedArgs
//////////////////////////////////////////////////////////////////////////////// -
_procedures
-
_functions
-
_debugging
private final boolean _debugging- See Also:
-
_messageFormatter
-
-
Constructor Details
-
SignatureChecker
////////////////////////////////////////////////////////////////////////////////
-
-
Method Details
-
main
//////////////////////////////////////////////////////////////////////////////// -
execute
private void execute()Get a connection to a database and then match the signatures of routines in that database.
-
matchSignatures
Match the signatures of routines in the database attached to this connection.
- Parameters:
conn- This connection- Throws:
SQLException
-
matchProcedures
Match the signatures of procedures in this database.
- Parameters:
conn- The connection to use to access the database- Throws:
SQLException
-
matchFunctions
Match the signatures of functions in this database.
- Parameters:
conn- The connection to use to access the database- Throws:
SQLException
-
makeReadableSignature
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
Find all of the user-declared procedures.
- Parameters:
dbmd- the database metadata of the database- Throws:
SQLException
-
countProcedureArgs
Count up the arguments to the user-coded procedures in
_proceduresand update that data structure accordingly- Parameters:
dbmd- the database metadata of the database- Throws:
SQLException
-
findFunctions
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
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
Prepared a routine invocation in order to check whether it matches a Java method.
- Parameters:
conn- The connection to the databasequery- The SQL to preparereadableSignature- the signature: printed if prepare fails
-
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.- Returns:
- a connection to the database
- Throws:
SQLException
-
prepareStatement
- Throws:
SQLException
-
printUsage
private static void printUsage() -
printThrowable
-
println
-
isSystemSchema
Return true if the schema is a system schema.- Parameters:
schema- the schema to check- Returns:
trueif the schema is a system schema
-
putProcedure
Store a procedure descriptor. Updates_procedures.- Parameters:
schema- schema of the procedurename- of a procedure
-
getProcedure
Get a procedure descriptor from_procedures.- Parameters:
idx- The index of the procedure in_procedures.- Returns:
- a procedure descriptor
-
putFunction
Store a function descriptor. Updates_functions.- Parameters:
schema- The schema of the functionname- The name of the functionisTableFunction-trueiff the function is a table function
-
getFunction
Get a function descriptor from_functions.- Parameters:
idx- The index of the procedure in_functions.- Returns:
- a function descriptor
-
formatMessage
-
getMessageFormatter
Get the message resource.- Returns:
- localized resource
-