Unable to connect to Oracle with JDBC [message #682273] |
Wed, 14 October 2020 16:46 |
|
andrewah
Messages: 2 Registered: October 2020
|
Junior Member |
|
|
Hi,
I'm executing a JUnit test from Gradle. It attempts to connect to Oracle. The test is being executed from a server running Red Hat 7.8 (Maipo).
The attempt to get a connection fails with a NullPointerException.
The code behind the test runs fine when pasted into a standalone Java application.
I've run it using the diagnostic version of Oracle's JDBC drivers and the output is here:
Oct 14, 2020 11:10:30 PM oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource$BlockReleaserListener <init>
INFO: setCollectionUsageThreshold<PS Old Gen>(644559667)
Oct 14, 2020 11:10:30 PM oracle.jdbc.driver.T4CConnection logon
INFO: Connection.logon: oracle.jdbc.driver.T4CConnection@e26fa72
Oct 14, 2020 11:10:30 PM oracle.jdbc.driver.T4CConnection logon
INFO: Operating System Process Identifier (SPID): null
Oct 14, 2020 11:10:30 PM oracle.jdbc.driver.T4CConnection logon
INFO: DRCP Enabled: false
The only thing different in this output compared to when I run the code as a standalone application is the line mentioning the SPID. When I run it standalone, a SPID number is reported & when I don't it's null. I have no idea why it would be null.
If anyone does have any ideas please let me know!!!
Thanks,
Andrew.
NB. For reference, the code is here:
public Connection getConnection () throws Exception
{
oracle.jdbc.OracleConnection conn = null;
oracle.jdbc.pool.OracleDataSource oraDataSrc = new oracle.jdbc.pool.OracleDataSource ();
oraDataSrc.setURL ( "jdbc:oracle:thin:@//thing-scan.xxx.net:1521/xxx" );
LOG.info ( "The jdbc URL has been set = " + oraDataSrc.getURL() );
oraDataSrc.setUser ( "BOBBINS" );
LOG.info ( "Username has been set to " + oraDataSrc.getUser () );
oraDataSrc.setPassword ( "NONSENSE" );
LOG.info ( "Password has been set ");
conn = ( oracle.jdbc.OracleConnection ) oraDataSrc.getConnection();
LOG.info ("did we get here?");
return conn;
}
|
|
|
|
|