Class DBMSMetadata
- java.lang.Object
-
- net.sourceforge.pmd.util.database.DBMSMetadata
-
-
Field Summary
Fields Modifier and Type Field Description protected CallableStatement
callableStatement
CallableStatement to return source code.protected Connection
connection
Connection managementprotected DBURI
dburi
DBURIprotected String
returnSourceCodeObjectsStatement
Procedural statement to return list of source code objects.protected String
returnSourceCodeStatement
Procedural statement to return source code.protected int
returnType
Types
value representing the type returned bycallableStatement
Currently only java.sql.Types.String and java.sql.Types.Clob are supported
-
Constructor Summary
Constructors Constructor Description DBMSMetadata(String user, String password, DBURI dbURI)
Define database connection and source code to retrieve with explicit database username and password.DBMSMetadata(Connection c)
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Connection
getConnection()
Return JDBC Connection for direct JDBC access to the specified database.Reader
getSourceCode(String objectType, String name, String schema)
return source code textReader
getSourceCode(SourceObject sourceObject)
Return source code text from the database.List<SourceObject>
getSourceObjectList()
Return all source code objects associated with any associated DBURI.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.
-
-
-
Field Detail
-
dburi
protected DBURI dburi
DBURI
-
connection
protected Connection connection
Connection management
-
returnSourceCodeObjectsStatement
protected String returnSourceCodeObjectsStatement
Procedural statement to return list of source code objects.
-
returnSourceCodeStatement
protected String returnSourceCodeStatement
Procedural statement to return source code.
-
callableStatement
protected CallableStatement callableStatement
CallableStatement to return source code.
-
returnType
protected int returnType
Types
value representing the type returned bycallableStatement
Currently only java.sql.Types.String and java.sql.Types.Clob are supported
-
-
Constructor Detail
-
DBMSMetadata
public DBMSMetadata(Connection c) throws SQLException
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
-DBURI
containing 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
-DBURI
containing 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(DBURI dbURI) throws SQLException, ClassNotFoundException
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
-DBURI
containing 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 Detail
-
getConnection
public Connection getConnection() throws SQLException
Return JDBC Connection for direct JDBC access to the specified database.- Returns:
- I=JDBC Connection
- Throws:
SQLException
-
getSourceCode
public Reader getSourceCode(SourceObject sourceObject) throws SQLException
Return source code text from the database.- Parameters:
sourceObject
- object- Returns:
- source code
- Throws:
SQLException
-
getSourceCode
public Reader getSourceCode(String objectType, String name, String schema) throws SQLException
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
public List<SourceObject> 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
-
-