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 boolean
private final ArrayList
<SignatureChecker.SQLRoutine> private static LocalizedResource
private final SignatureChecker.ParsedArgs
private final ArrayList
<SignatureChecker.SQLRoutine> private static final String[]
private static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
checkSignature
(Connection conn, String query, String readableSignature) Prepared a routine invocation in order to check whether it matches a Java method.private void
Count up the arguments to the user-coded procedures.private void
Count up the arguments to the user-coded procedures in_procedures
and update that data structure accordinglyprivate void
execute()
Get a connection to a database and then match the signatures of routines in that database.private void
Find all of the user-declared functions.private void
Find all of the user-declared procedures.private static String
formatMessage
(String key, Object... args) Format a localizable message.private SignatureChecker.SQLRoutine
getFunction
(int idx) Get a function descriptor from_functions
.private Connection
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
Get the message resource.private SignatureChecker.SQLRoutine
getProcedure
(int idx) Get a procedure descriptor from_procedures
.private boolean
isSystemSchema
(String schema) Return true if the schema is a system schema.static void
private String
Make a human readable signature for a routine.private void
matchFunctions
(Connection conn) Match the signatures of functions in this database.private void
matchProcedures
(Connection conn) Match the signatures of procedures in this database.private void
matchSignatures
(Connection conn) Match the signatures of routines in the database attached to this connection.private PreparedStatement
prepareStatement
(Connection conn, String text) private static void
private static void
private static void
private void
putFunction
(String schema, String name, boolean isTableFunction) Store a function descriptor.private void
putProcedure
(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
_procedures
and 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:
true
if 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
-true
iff 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
Format a localizable message.- Parameters:
key
- The message key by which we located the localized textargs
- Any arguments to the localized text to be filled in- Returns:
- A localized message
-
getMessageFormatter
Get the message resource.- Returns:
- localized resource
-