Below is the code to connect to remote database. Datasource is configured on a remote weblogic server. I want to use the same jndi. I used ddmp-wlfullclient-12.2.1.3.jar as dependency.
This program is a standalone java application.
Hashtable<String,String> ht = new Hashtable<>();
ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://<servername>:<port>");
Context ctx = new InitialContext(ht);
javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("jdbc/<jndiname>");
java.sql.Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
stmt.execute("select * from table");
ResultSet rs = stmt.getResultSet();
But I am getting the below exception.
java.lang.ClassCastException: weblogic.jdbc.common.internal.RmiDataSource_12214_WLStub cannot be cast to javax.sql.DataSource
Could someone guide me in getting it resolved.
I don't want to maintain credentials in my program in any format