Jeff Finger
2001-12-18 12:18:05 UTC
I, too, am having the same problem trying to read an Oracle schema. I wonder if the hack that Michael sent for SchemaFactory is what
he intended? After piecing the lines back together, I get the appended snippet. But,....
1. The variable "types" is never used.
2. The presence of substring ":oracle" is checked inside a conditional that has already checked for this substring.
3. The method is not complete.
Sorry if I am being dense, but it looks like something is missing here.
Thanks a lot,
Jeff Finger
String[] types= null;
if( connectionSettings.databaseURL.indexOf(":oracle") > -1) {
// no significance for Oracle ? must me null ?
// alegedly significant for Sybase with
// multiple databases(catalogs) per instance
if( "".equals( connectionSettings.catalog ) ){
connectionSettings.catalog = null;
}
if( connectionSettings.catalog != null ) {
connectionSettings.catalog =
connectionSettings.catalog.toUpperCase();
}
if( "".equals( connectionSettings.schema ) ) {
// in case of oracle it will also cause retrieval of
// many other objects
// inlcuding dictionary views, thus processing slowing down
// "" may cause it not to retrieve anything
connectionSettings.schema = null;
}
if( connectionSettings.schema != null &&
connectionSettings.databaseURL.indexOf(":oracle") > -1) {
//usually the access rights are set up so that you can
// only query your schema
// ie. schema = username
connectionSettings.schema =
connectionSettings.schema.toUpperCase();
}
types = new String[] {"TABLE","VIEW"};
// null will also retrieve objects for which only
// synonyms exists, but this objects will not
// be successfully processed anyway - did not check why
// -probably columns not retrieved
System.out.println("connectionSettings.schema = " +
connectionSettings.schema );
}
----------------
/**
* @todo figure out how to pick driver at runtime and use it.
classloader
* problem. for now, must be on cp.
* @todo split into several methods
* @todo do smarter primkey guessing. Have a way to mark
fields/primkeys as
* "guessed"
* @todo Write javadocs for method parameter
* @todo Write javadocs for return value
* @todo Write javadocs for exception
* @param connectionSettings Describe what the parameter does
* @return Describe the return value
* @exception MiddlemanException Describe the exception
*/
public static Schema createSchema(ConnectionSettings
connectionSettings)
throws MiddlemanException {
Schema result = new Schema();
try {
Class.forName(connectionSettings.JDBCDriver).newInstance();
Connection connection =
DriverManager.getConnection(connectionSettings.databaseURL,
connectionSettings.username, connectionSettings.password);
DatabaseMetaData databaseMetaData = connection.getMetaData();
// get the tables
_log.debug("-- tables --");
String sse = databaseMetaData.getSearchStringEscape();
ArrayList tables = new ArrayList();
String[] types= null;
if(
connectionSettings.databaseURL.indexOf(":oracle") > -1) {
// no significance for Oracle ? must
me null ?
// alegedly significant for Sybase
with multiple databases(catalogs) per instance
if( "".equals(
connectionSettings.catalog ) ){
connectionSettings.catalog =
null;
}
if( connectionSettings.catalog !=
null ) {
connectionSettings.catalog =
connectionSettings.catalog.toUpperCase();
}
if( "".equals(
connectionSettings.schema ) ){
// in case of oracle it will
also cause retrieval of many other objects
// inlcuding dictionary views,
thus processing slowing down
// "" may cause it not to
retirieve anything
connectionSettings.schema =
null;
}
if( connectionSettings.schema !=
null && connectionSettings.databaseURL.indexOf(":oracle") > -1)
{
//usually the access rights are
set up so that you can only query your schema
// ie. schema = username
connectionSettings.schema =
connectionSettings.schema.toUpperCase();
}
types = new String[]
{"TABLE","VIEW"};
//null will also retrieve objects
for which only synonyms exists, but this objects will not
//be successfully processed anyway -
did not check why -probably columns not retrieved
System.out.println("connectionSettings.schema = " +
connectionSettings.schema );
}
----------------
he intended? After piecing the lines back together, I get the appended snippet. But,....
1. The variable "types" is never used.
2. The presence of substring ":oracle" is checked inside a conditional that has already checked for this substring.
3. The method is not complete.
Sorry if I am being dense, but it looks like something is missing here.
Thanks a lot,
Jeff Finger
String[] types= null;
if( connectionSettings.databaseURL.indexOf(":oracle") > -1) {
// no significance for Oracle ? must me null ?
// alegedly significant for Sybase with
// multiple databases(catalogs) per instance
if( "".equals( connectionSettings.catalog ) ){
connectionSettings.catalog = null;
}
if( connectionSettings.catalog != null ) {
connectionSettings.catalog =
connectionSettings.catalog.toUpperCase();
}
if( "".equals( connectionSettings.schema ) ) {
// in case of oracle it will also cause retrieval of
// many other objects
// inlcuding dictionary views, thus processing slowing down
// "" may cause it not to retrieve anything
connectionSettings.schema = null;
}
if( connectionSettings.schema != null &&
connectionSettings.databaseURL.indexOf(":oracle") > -1) {
//usually the access rights are set up so that you can
// only query your schema
// ie. schema = username
connectionSettings.schema =
connectionSettings.schema.toUpperCase();
}
types = new String[] {"TABLE","VIEW"};
// null will also retrieve objects for which only
// synonyms exists, but this objects will not
// be successfully processed anyway - did not check why
// -probably columns not retrieved
System.out.println("connectionSettings.schema = " +
connectionSettings.schema );
}
----------------
/**
* @todo figure out how to pick driver at runtime and use it.
classloader
* problem. for now, must be on cp.
* @todo split into several methods
* @todo do smarter primkey guessing. Have a way to mark
fields/primkeys as
* "guessed"
* @todo Write javadocs for method parameter
* @todo Write javadocs for return value
* @todo Write javadocs for exception
* @param connectionSettings Describe what the parameter does
* @return Describe the return value
* @exception MiddlemanException Describe the exception
*/
public static Schema createSchema(ConnectionSettings
connectionSettings)
throws MiddlemanException {
Schema result = new Schema();
try {
Class.forName(connectionSettings.JDBCDriver).newInstance();
Connection connection =
DriverManager.getConnection(connectionSettings.databaseURL,
connectionSettings.username, connectionSettings.password);
DatabaseMetaData databaseMetaData = connection.getMetaData();
// get the tables
_log.debug("-- tables --");
String sse = databaseMetaData.getSearchStringEscape();
ArrayList tables = new ArrayList();
String[] types= null;
if(
connectionSettings.databaseURL.indexOf(":oracle") > -1) {
// no significance for Oracle ? must
me null ?
// alegedly significant for Sybase
with multiple databases(catalogs) per instance
if( "".equals(
connectionSettings.catalog ) ){
connectionSettings.catalog =
null;
}
if( connectionSettings.catalog !=
null ) {
connectionSettings.catalog =
connectionSettings.catalog.toUpperCase();
}
if( "".equals(
connectionSettings.schema ) ){
// in case of oracle it will
also cause retrieval of many other objects
// inlcuding dictionary views,
thus processing slowing down
// "" may cause it not to
retirieve anything
connectionSettings.schema =
null;
}
if( connectionSettings.schema !=
null && connectionSettings.databaseURL.indexOf(":oracle") > -1)
{
//usually the access rights are
set up so that you can only query your schema
// ie. schema = username
connectionSettings.schema =
connectionSettings.schema.toUpperCase();
}
types = new String[]
{"TABLE","VIEW"};
//null will also retrieve objects
for which only synonyms exists, but this objects will not
//be successfully processed anyway -
did not check why -probably columns not retrieved
System.out.println("connectionSettings.schema = " +
connectionSettings.schema );
}
----------------