eu.etaxonomy.cdm.io.common
Class Source

java.lang.Object
  extended by eu.etaxonomy.cdm.io.common.Source

public class Source
extends Object

Creates Cursors from extern relational DB. Used only for developpers convienence hence undocumented. You may create input cursors in any other way you want

Author:
Andreas Müller

Field Summary
static String ACCESS
           
static String DB2
           
static String EXCEL
           
static String ODDBC
           
static String ORACLE
           
static String SELECT_CURSOR
           
static String SELECT_DIRECT
           
static String SQL_SERVER_2005
           
static String SQL_SERVER_2008
           
 
Constructor Summary
Source(ICdmDataSource cdmDataSource)
          Creates a source with parameters of a ICdmDataSource instance
Source(String dbms, String server, String db)
          Creates a source and sets the according variables
Source(String dbms, String server, String db, boolean cursor)
          Creates a source and sets the parameter.
Source(String dbms, String server, String db, int port)
          Creates a source and sets the parameter.
Source(String dbms, String server, String db, String query)
          Creates a source and sets the query string
 
Method Summary
 boolean checkColumnExists(String tableName, String dbAttribute)
          Checks if an attribute exists in the database schema.
 Connection getConnection()
          Returns the connection.
 String getDatabase()
           
 ResultSet getResultSet()
          Returns the Resultset for Sources query.
 ResultSet getResultSet(String query)
          Returns the Resultset for query 'query'.
 String getServer()
           
 boolean isDoLog()
           
 void setDoLog(boolean doLog)
           
 Source setPassword(String pwd)
          Sets the password.
 Source setPort(int port)
          Sets the port.
 Source setQuery(String query)
           
 Source setUserAndPwd(String userName, String pwd)
          Sets the username and password.
 Source setUsername(String userName)
          Sets the username.
 String toString()
           
 int update(String updateStatement)
          Executes an insert, update or delete statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SQL_SERVER_2005

public static final String SQL_SERVER_2005
See Also:
Constant Field Values

SQL_SERVER_2008

public static final String SQL_SERVER_2008
See Also:
Constant Field Values

ACCESS

public static final String ACCESS
See Also:
Constant Field Values

EXCEL

public static final String EXCEL
See Also:
Constant Field Values

ODDBC

public static final String ODDBC
See Also:
Constant Field Values

ORACLE

public static final String ORACLE
See Also:
Constant Field Values

DB2

public static final String DB2
See Also:
Constant Field Values

SELECT_DIRECT

public static final String SELECT_DIRECT
See Also:
Constant Field Values

SELECT_CURSOR

public static final String SELECT_CURSOR
See Also:
Constant Field Values
Constructor Detail

Source

public Source(String dbms,
              String server,
              String db)
Creates a source and sets the according variables

Parameters:
dbms - name of database management system (e.g. "SQLServer", "Access", "Excel", "Oracle"
server - name of server, if dbms is ODBC, this must be the ODBC name
db - name of database

Source

public Source(String dbms,
              String server,
              String db,
              String query)
Creates a source and sets the query string

Parameters:
dbms - name of database management system (e.g. "SQLServer", "Access", "Excel", "Oracle"
server - name of server, if dbms is ODBC, this must be the ODBC name
db - name of database
query - the query

Source

public Source(String dbms,
              String server,
              String db,
              boolean cursor)
Creates a source and sets the parameter.

Parameters:
cursor - access mode, if true 'cursor', if false 'direct'

Source

public Source(String dbms,
              String server,
              String db,
              int port)
Creates a source and sets the parameter. If port is -1 the databases default port is used.

Parameters:
dbms - name of database management system (e.g. "SQLServer", "Access", "Excel", "Oracle"
server - name of server, if dbms is ODBC, this must be the ODBC name
db - name of database
port - the databases port (-1: use default port)

Source

public Source(ICdmDataSource cdmDataSource)
Creates a source with parameters of a ICdmDataSource instance

Parameters:
cdmDataSource -
Method Detail

getResultSet

public ResultSet getResultSet(String query)
Returns the Resultset for query 'query'. Does not change the Sources query-string!!

Returns:
Resultset for the query.

update

public int update(String updateStatement)
Executes an insert, update or delete statement. Returns the number of rows changed or -1 if updatedStatement was 0 or and error occurred. Does not change the Sources query-string!!

Returns:
Resultset for the query.

getResultSet

public ResultSet getResultSet()
Returns the Resultset for Sources query.

Returns:
Resultset for the Sources query

getConnection

public Connection getConnection()
Returns the connection.

Returns:
the Sources connection

setQuery

public Source setQuery(String query)
Parameters:
query -

setUsername

public Source setUsername(String userName)
Sets the username.

Parameters:
userName -

setPassword

public Source setPassword(String pwd)
Sets the password.

Parameters:
pwd -

setUserAndPwd

public Source setUserAndPwd(String userName,
                            String pwd)
Sets the username and password.

Parameters:
userName -
pwd -

setPort

public Source setPort(int port)
Sets the port.

Parameters:
userName -
pwd -

getDatabase

public String getDatabase()

getServer

public String getServer()

isDoLog

public boolean isDoLog()

setDoLog

public void setDoLog(boolean doLog)

checkColumnExists

public boolean checkColumnExists(String tableName,
                                 String dbAttribute)
                          throws NoSuchMethodException
Checks if an attribute exists in the database schema. At the moment only supported for SQL Server. TODO implement for others.

Parameters:
tableName -
dbAttribute -
Returns:
Throws:
org.apache.http.MethodNotSupportedException
NoSuchMethodException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007-2013 EDIT. All Rights Reserved.