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
Modifier and Type | Class and Description |
---|---|
(package private) static class |
SignatureChecker.ParsedArgs |
(package private) class |
SignatureChecker.SQLRoutine |
Modifier and Type | Field and Description |
---|---|
private boolean |
_debugging |
private java.util.ArrayList<SignatureChecker.SQLRoutine> |
_functions |
private static LocalizedResource |
_messageFormatter |
private SignatureChecker.ParsedArgs |
_parsedArgs |
private java.util.ArrayList<SignatureChecker.SQLRoutine> |
_procedures |
private static java.lang.String[] |
SYSTEM_SCHEMAS |
private static java.lang.String |
WILDCARD |
Modifier | Constructor and Description |
---|---|
private |
SignatureChecker(SignatureChecker.ParsedArgs parsedArgs) |
Modifier and Type | Method and Description |
---|---|
private void |
checkSignature(java.sql.Connection conn,
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 in
_procedures and update that data structure accordingly
|
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,
java.lang.Object... args)
Format a localizable message.
|
private SignatureChecker.SQLRoutine |
getFunction(int idx)
Get a function descriptor from
_functions
. |
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 from
_procedures . |
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.
|
private static final java.lang.String WILDCARD
private static final java.lang.String[] SYSTEM_SCHEMAS
private final SignatureChecker.ParsedArgs _parsedArgs
private final java.util.ArrayList<SignatureChecker.SQLRoutine> _procedures
private final java.util.ArrayList<SignatureChecker.SQLRoutine> _functions
private final boolean _debugging
private static LocalizedResource _messageFormatter
private SignatureChecker(SignatureChecker.ParsedArgs parsedArgs)
public static void main(java.lang.String[] args)
private void execute()
Get a connection to a database and then match the signatures of routines in that database.
private void matchSignatures(java.sql.Connection conn) throws java.sql.SQLException
Match the signatures of routines in the database attached to this connection.
conn
- This connectionjava.sql.SQLException
private void matchProcedures(java.sql.Connection conn) throws java.sql.SQLException
Match the signatures of procedures in this database.
conn
- The connection to use to access the databasejava.sql.SQLException
private void matchFunctions(java.sql.Connection conn) throws java.sql.SQLException
Match the signatures of functions in this database.
conn
- The connection to use to access the databasejava.sql.SQLException
private java.lang.String makeReadableSignature(SignatureChecker.SQLRoutine routine)
Make a human readable signature for a routine. This can be used in error messages.
routine
- the routine for which we want a signatureprivate void findProcedures(java.sql.DatabaseMetaData dbmd) throws java.sql.SQLException
Find all of the user-declared procedures.
dbmd
- the database metadata of the databasejava.sql.SQLException
private void countProcedureArgs(java.sql.DatabaseMetaData dbmd) throws java.sql.SQLException
Count up the arguments to the user-coded procedures in
_procedures
and update that data structure accordingly
dbmd
- the database metadata of the databasejava.sql.SQLException
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. Update _functions
.
dbmd
- the database metadata of the databasejava.sql.SQLException
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.
Update _functions
.
dbmd
- the database metadata of the databasejava.sql.SQLException
private void checkSignature(java.sql.Connection conn, java.lang.String query, java.lang.String readableSignature)
Prepared a routine invocation in order to check whether it matches a Java method.
conn
- The connection to the databasequery
- The SQL to preparereadableSignature
- the signature: printed if prepare failsprivate java.sql.Connection getJ2SEConnection() throws java.sql.SQLException
java.sql.SQLException
private java.sql.PreparedStatement prepareStatement(java.sql.Connection conn, java.lang.String text) throws java.sql.SQLException
java.sql.SQLException
private static void printUsage()
private static void printThrowable(java.lang.Throwable t)
private static void println(java.lang.String text)
private boolean isSystemSchema(java.lang.String schema)
schema
- the schema to checktrue
if the schema is a system schemaprivate void putProcedure(java.lang.String schema, java.lang.String name)
_procedures
.schema
- schema of the procedurename
- of a procedureprivate SignatureChecker.SQLRoutine getProcedure(int idx)
_procedures
.idx
- The index of the procedure in _procedures
.private void putFunction(java.lang.String schema, java.lang.String name, boolean isTableFunction)
_functions
.schema
- The schema of the functionname
- The name of the functionisTableFunction
- true
iff the function is a table functionprivate SignatureChecker.SQLRoutine getFunction(int idx)
_functions
.idx
- The index of the procedure in _functions
.private static java.lang.String formatMessage(java.lang.String key, java.lang.Object... args)
key
- The message key by which we located the localized textargs
- Any arguments to the localized text to be filled inprivate static LocalizedResource getMessageFormatter()
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.