Details
Description
Hi,
I need to access an Oracle data store using the following parameters:
USER: xxx
PASSWD: xxx
DATABASE: (DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = xxx)(PORT = xxxx))(ADDRESS = (PROTOCOL = TCP)(HOST = xxx)(PORT = xxxx))(LOAD_BALANCE = yes))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=xxx.xxx.xxx.xx)(FAILOVER_MODE=(TYPE=SELECT)(METHOD=BASIC)(RETRIES=180)(DELAY=5))))
When you run the OracleNGDataStoreFactory.getJDBCUrl (Map params) protected method, the execution of the 'lookUp' function throws an IOException as the HOST and PORT parameters are required.
This is the method code:
...
@Override
protected String getJDBCUrl(Map params) throws IOException
...
In this method if the DATABASE parameter starts with "(", the HOST and PORT parameters are not used because the function returns 'JDBC_PATH + db'.
I have consulted the Oracle documentation at this link:
http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.html#top (in the 'Connections' section)
and I see that the HOST and PORT parameters are not always required to compose the JDBC URL.
In the current 'getJDBCUrl' method the DATABASE parameter is alwais required to compose the JDBC URL but, in the JDBCDataStoreFactory
class, this parameter not have the "required" flag set up.
To resolve this problem I modified the OracleNGDataStoreFactory class as follow:
1) Marking HOST and PORT parameters as not "required" and DATABASE as "required":
...
/** parameter for database port */
public static final Param PORT = new Param("port", Integer.class, "Port", false, 1521);
/** parameter for database host */
public static final Param HOST = new Param("host", String.class, "Host", false, "localhost");
/** parameter for database instance */
public static final Param DATABASE = new Param("database", String.class, "Database", true);
...
2) Modifying 'getJDBCurl' method as follow:
...
@Override
protected String getJDBCUrl(Map params) throws IOException
...
3) Modifying the 'setupParameters' method introducing the new HOST, PORT and DATABASE definitions:
...
@Override
protected void setupParameters(Map parameters)
...
Regards
I wonder why you people cannot just use "+" to concatenate strings and always has to reach to less readable ways to do the work. Btw, the one you used is _less_ efficient than using "+" as far as I know.
Please revert those changes