Class DBMSMetadata
java.lang.Object
net.sourceforge.pmd.util.database.DBMSMetadata
Wrap JDBC connection for use by PMD:
DBURI parameters specify the
source code to be passed to PMD.- Author:
- sturton
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CallableStatementCallableStatement to return source code.protected ConnectionConnection managementprotected DBURIDBURIprotected StringProcedural statement to return list of source code objects.protected StringProcedural statement to return source code.protected intTypesvalue representing the type returned bycallableStatementCurrently only java.sql.Types.String and java.sql.Types.Clob are supported -
Constructor Summary
ConstructorsConstructorDescriptionDBMSMetadata(String user, String password, DBURI dbURI) Define database connection and source code to retrieve with explicit database username and password.Minimal constructorDBMSMetadata(Properties properties, DBURI dbURI) Define database connection and source code to retrieve with database properties.DBMSMetadata(DBURI dbURI) Define database connection and source code to retrieve. -
Method Summary
Modifier and TypeMethodDescriptionReturn JDBC Connection for direct JDBC access to the specified database.getSourceCode(String objectType, String name, String schema) return source code textgetSourceCode(SourceObject sourceObject) Return source code text from the database.Return all source code objects associated with any associated DBURI.getSourceObjectList(List<String> languages, List<String> schemas, List<String> sourceCodeTypes, List<String> sourceCodeNames) Return all source code objects associated with the specified languages, schemas, source code types and source code names.
-
Field Details
-
dburi
DBURI -
connection
Connection management -
returnSourceCodeObjectsStatement
Procedural statement to return list of source code objects. -
returnSourceCodeStatement
Procedural statement to return source code. -
callableStatement
CallableStatement to return source code. -
returnType
protected int returnTypeTypesvalue representing the type returned bycallableStatementCurrently only java.sql.Types.String and java.sql.Types.Clob are supported
-
-
Constructor Details
-
DBMSMetadata
Minimal constructor- Parameters:
c- JDBC Connection- Throws:
SQLException
-
DBMSMetadata
public DBMSMetadata(String user, String password, DBURI dbURI) throws SQLException, MalformedURLException, ClassNotFoundException Define database connection and source code to retrieve with explicit database username and password.- Parameters:
user- Database usernamepassword- Database passworddbURI-DBURIcontaining JDBC connection plus parameters to specify source code.- Throws:
SQLException- on failing to create JDBC connectionMalformedURLException- on attempting to connect with malformed JDBC URLClassNotFoundException- on failing to locate the JDBC driver class.
-
DBMSMetadata
public DBMSMetadata(Properties properties, DBURI dbURI) throws SQLException, MalformedURLException, ClassNotFoundException Define database connection and source code to retrieve with database properties.- Parameters:
properties- database settings such as database username, passworddbURI-DBURIcontaining JDBC connection plus parameters to specify source code.- Throws:
SQLException- on failing to create JDBC connectionMalformedURLException- on attempting to connect with malformed JDBC URLClassNotFoundException- on failing to locate the JDBC driver class.
-
DBMSMetadata
Define database connection and source code to retrieve.This constructor is reliant on database username and password embedded in the JDBC URL or defaulted from the
DBURI'sDriverType.- Parameters:
dbURI-DBURIcontaining JDBC connection plus parameters to specify source code.- Throws:
SQLException- on failing to create JDBC connectionClassNotFoundException- on failing to locate the JDBC driver class.
-
-
Method Details
-
getConnection
Return JDBC Connection for direct JDBC access to the specified database.- Returns:
- I=JDBC Connection
- Throws:
SQLException
-
getSourceCode
Return source code text from the database.- Parameters:
sourceObject- object- Returns:
- source code
- Throws:
SQLException
-
getSourceCode
return source code text- Parameters:
objectType-name- Source Code nameschema- Owner of the code- Returns:
- Source code text.
- Throws:
SQLException- on failing to retrieve the source Code text
-
getSourceObjectList
Return all source code objects associated with any associated DBURI.- Returns:
-
getSourceObjectList
public List<SourceObject> getSourceObjectList(List<String> languages, List<String> schemas, List<String> sourceCodeTypes, List<String> sourceCodeNames) Return all source code objects associated with the specified languages, schemas, source code types and source code names.Each parameter may be null and the appropriate field from any related DBURI is assigned, defaulting to the normal SQL wildcard expression ("%").
- Parameters:
languages- Optional list of languages to search forschemas- Optional list of schemas to search forsourceCodeTypes- Optional list of source code types to search forsourceCodeNames- Optional list of source code names to search for
-