net.sourceforge.pmd.util.database
Class DBMSMetadata

java.lang.Object
  extended by net.sourceforge.pmd.util.database.DBMSMetadata

public class DBMSMetadata
extends Object

Wrap JDBC connection for use by PMD: DBURI parameters specify the source code to be passed to PMD.

Author:
sturton

Field Summary
protected  CallableStatement callableStatement
          CallableStatement to return source code.
protected  Connection connection
          Connection management
protected  DBURI dburi
          DBURI
protected  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 by callableStatement Currently only java.sql.Types.String and java.sql.Types.Clob are supported
 
Constructor Summary
DBMSMetadata(Connection c)
          Minimal constructor
DBMSMetadata(DBURI dbURI)
          Define database connection and source code to retrieve.
DBMSMetadata(Properties properties, DBURI dbURI)
          Define database connection and source code to retrieve with database properties.
DBMSMetadata(String user, String password, DBURI dbURI)
          Define database connection and source code to retrieve with explicit database username and password.
 
Method Summary
 Connection getConnection()
          Return JDBC Connection for direct JDBC access to the specified database.
 Reader getSourceCode(SourceObject sourceObject)
          Return source code text from the database.
 Reader getSourceCode(String objectType, String name, String schema)
          return source code text
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 by callableStatement 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 username
password - Database password
dbURI - DBURI containing JDBC connection plus parameters to specify source code.
Throws:
SQLException - on failing to create JDBC connection
MalformedURLException - on attempting to connect with malformed JDBC URL
ClassNotFoundException - 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, password
dbURI - DBURI containing JDBC connection plus parameters to specify source code.
Throws:
SQLException - on failing to create JDBC connection
MalformedURLException - on attempting to connect with malformed JDBC URL
ClassNotFoundException - 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's DriverType.

Parameters:
user - Database username
password - Database password
dbURI - DBURI containing JDBC connection plus parameters to specify source code.
Throws:
SQLException - on failing to create JDBC connection
ClassNotFoundException - 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:
source - 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 name
schema - 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 for
schemas - Optional list of schemas to search for
sourceCodeTypes - Optional list of source code types to search for
sourceCodeNames - Optional list of source code names to search for


Copyright © 2002-2015 InfoEther. All Rights Reserved.