Class AccessDatabase
java.lang.Object
org.apache.derby.impl.tools.planexporter.AccessDatabase
This class will perform the database connection establishment,
querying the database, shut downing the database.
Created under DERBY-4587-PlanExporter tool
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Connectionprivate TreeNode[]private intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate final Stringprivate static final intprivate static final intprivate static final intprivate static final intprivate final Stringprivate final booleanprivate static final intprivate static final intprivate String -
Constructor Summary
ConstructorsConstructorDescriptionAccessDatabase(String dburl, String aSchema, String aQuery) AccessDatabase(Connection aConn, String aSchema, String aQuery) -
Method Summary
Modifier and TypeMethodDescriptionvoidclosing the connection to the databaseprivate static ConnectioncreateConnection(String dbURL) private voidcreateXMLData(String qry, int x) Create XML data based on the query that's passed in.voidThis method creates the queries such that after execution of the query it will return XML data fragments.private static StringescapeForXML(String text) Escape characters that have a special meaning in XML.private StringescapeInAttribute(String text) This method is needed since in the case of XML attributes we have to filter the quotation (") marks that is compulsory. eg: scanned_object="A "quoted" table name";private voidfindChildren(int idx, int dep) private voidgetChildren(int currentLevel, String id) TreeNode[]getData()intgetDepth()getQuery()Generating the XML treeindent(int j) booleanvoidmarking the depth of each elementprivate intprivate booleanCheck if there is a schema in the database that matches the schema name that was passed in to this instance.private voidSet the schema of the current connection to the XPLAIN schema in which the statistics can be found.stmtID()time()boolean
-
Field Details
-
conn
-
schema
-
query
-
schemaExists
private final boolean schemaExists -
data
-
depth
private int depth -
xmlDetails
-
ID
private static final int ID- See Also:
-
P_ID
private static final int P_ID- See Also:
-
NODE_TYPE
private static final int NODE_TYPE- See Also:
-
NO_OF_OPENS
private static final int NO_OF_OPENS- See Also:
-
INPUT_ROWS
private static final int INPUT_ROWS- See Also:
-
RETURNED_ROWS
private static final int RETURNED_ROWS- See Also:
-
VISITED_PAGES
private static final int VISITED_PAGES- See Also:
-
SCAN_QUALIFIERS
private static final int SCAN_QUALIFIERS- See Also:
-
NEXT_QUALIFIERS
private static final int NEXT_QUALIFIERS- See Also:
-
SCANNED_OBJECT
private static final int SCANNED_OBJECT- See Also:
-
SCAN_TYPE
private static final int SCAN_TYPE- See Also:
-
SORT_TYPE
private static final int SORT_TYPE- See Also:
-
NO_OF_OUTPUT_ROWS_BY_SORTER
private static final int NO_OF_OUTPUT_ROWS_BY_SORTER- See Also:
-
-
Constructor Details
-
AccessDatabase
public AccessDatabase(String dburl, String aSchema, String aQuery) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException, NoSuchMethodException, InvocationTargetException - Parameters:
dburl-aSchema-aQuery-- Throws:
InstantiationExceptionIllegalAccessExceptionClassNotFoundExceptionSQLExceptionNoSuchMethodExceptionInvocationTargetException
-
AccessDatabase
- Parameters:
aConn-aSchema-aQuery-- Throws:
SQLException
-
-
Method Details
-
getQuery
- Returns:
- the stmt_id
-
getDepth
public int getDepth() -
createConnection
private static Connection createConnection(String dbURL) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException, NoSuchMethodException, InvocationTargetException -
setSchema
Set the schema of the current connection to the XPLAIN schema in which the statistics can be found.- Throws:
SQLException- if an error happens while accessing the database
-
schemaExists
Check if there is a schema in the database that matches the schema name that was passed in to this instance.- Throws:
SQLException
-
verifySchemaExistance
public boolean verifySchemaExistance() -
createXMLFragment
This method creates the queries such that after execution of the query it will return XML data fragments.
- Throws:
SQLException
-
getXmlString
-
getChildren
- Parameters:
currentLevel- level of the XML tree (0 based) of current nodeid- current node's stmt_id
-
indent
- Parameters:
j- indent needed- Returns:
- indent as a string
-
markTheDepth
public void markTheDepth()marking the depth of each element -
findChildren
private void findChildren(int idx, int dep) - Parameters:
idx- current element's indexdep- current examining depth
-
initializeDataArray
- Returns:
- whether the initialization is successful or not
- Throws:
SQLException
-
createXMLData
Create XML data based on the query that's passed in. The query should have exactly one parameter, which will be initialized to the statement id before the query is executed.- Parameters:
qry- query to be executed- Throws:
SQLException
-
noOfNodes
- Returns:
- total # of nodes
- Throws:
SQLException
-
statement
- Returns:
- the <statement> element
- Throws:
SQLException
-
escapeForXML
-
escapeInAttribute
-
time
- Returns:
- XPLAIN_TIME of SYSXPLAIN_STATEMENTS
- Throws:
SQLException
-
stmtID
- Returns:
- stmt_id as a XML element
-
closeConnection
public void closeConnection()closing the connection to the database -
getData
- Returns:
- data array of TreeNode Objects
-