Home » Developer & Programmer » JDeveloper, Java & XML » Configure JAAS for a connection to Oracle Database (Oracle Driver 12.2c)
Configure JAAS for a connection to Oracle Database [message #674183] Wed, 09 January 2019 09:24 Go to next message
maxlambrecht
Messages: 1
Registered: January 2019
Junior Member
I'm looking into how to connect a java app to a Oracle Database 12c, using the driver com.oracle:ojdbc8:12.2.0.1, and more specifically into how to use a custom LoginModule to authenticate the user. I think I'd have a jaas.conf that would look like this:

JaasClient {
com.test.MyLoginModule required
};

Does the Oracle Driver support for custom JAAS Login Modules ? In case it does, how it is configured ?
Re: Configure JAAS for a connection to Oracle Database [message #674186 is a reply to message #674183] Wed, 09 January 2019 10:19 Go to previous message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
bcm@bcm-laptop:~$ cat Conn.java
import java.sql.*;
class Conn {
  public static void main (String[] args) throws Exception
  {
   Class.forName ("oracle.jdbc.OracleDriver");
   Connection conn = DriverManager.getConnection
     ("jdbc:oracle:thin:@//localhost:1521/XE", "scott", "tiger");
                        // @//machineName:port/SID,   userid,  password
   try {
     Statement stmt = conn.createStatement();
     try {
       ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
       try {
         while (rset.next())
           System.out.println (rset.getString(1));   // Print col 1
       } 
       finally {
          try { rset.close(); } catch (Exception ignore) {}
       }
     } 
     finally {
       try { stmt.close(); } catch (Exception ignore) {}
     }
   } 
   finally {
     try { conn.close(); } catch (Exception ignore) {}
   }
  }
}
bcm@bcm-laptop:~$ javac Conn.java
bcm@bcm-laptop:~$ export CLASSPATH=/u01/app/oracle/product/11.2.0/dbhome_1/owb/wf/lib/ojdbc14.jar:.
bcm@bcm-laptop:~$ java Conn
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
bcm@bcm-laptop:~$

Previous Topic: Help with xmltable
Next Topic: Unable to change JRE version
Goto Forum:
  


Current Time: Thu Nov 21 06:28:40 CST 2024