Unanswered: JDBC problem -- javax.naming.NotContextException: Not an instance of DirContext
Does anybody know what the following JDBC stack trace indicates while connecting to a Oracle 18.104.22.168.0:
java.sql.SQLException: Io exception: JNDI Package failurejavax.naming.NotContextException: Not an instance of DirContext
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:334)
at oracle.jdbc.ttc7.TTC7Protocol.handleIOException(TT C7Protocol.java:3695)
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.j ava:352)
at oracle.jdbc.driver.OracleConnection.<init>(OracleC onnection.java:362)
at oracle.jdbc.driver.OracleDriver.getConnectionInsta nce(OracleDriver.java:536)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriv er.java:328)
at java.sql.DriverManager.getConnection(DriverManager .java:512)
at java.sql.DriverManager.getConnection(DriverManager .java:140)
The call I do is:
public class NotContextException
This exception is thrown when a naming operation proceeds to a point where a context is required to continue the operation, but the resolved object is not a context. For example, Context.destroy() requires that the named object be a context. If it is not, NotContextException is thrown. Another example is a non-context being encountered during the resolution phase of the Context methods.
It is also thrown when a particular subtype of context is required, such as a DirContext, and the resolved object is a context but not of the required subtype.
Synchronization and serialization issues that apply to NamingException apply directly here.
In my case the javax.naming.NotContextException "Not an instance of DirContext" was caused by the fact that I used a Properties object as argument to getConnection that contained some stuff (I think it was mappings of java.naming.* properties) that was not relevant to nor intended for the JDBC driver. After creating a new Properties instance that only contained "user" and "password" properties it works fine.