How to connect to oacle database with os authentication?

I have an oracle database of 11g , which is configured to connect through os authentication only with the alias name / tns of the database and does not require a username / password.

so I was wondering what is the easiest way to connect to the oracle database with os authentication through java, because I tried the oci example, as in this post java.lang.UnsatisfiedLinkError: no ocijdbc11 in java. library.path and stuck with it, so please advise if there are other easy ways to make this connection.

0
source share
1 answer

I was able to accomplish this using JDBC as follows:

    String dbServer="DBSERVER";
    String port="1521";
    String SID="DBNAME";
    String url = "jdbc:oracle:thin:@"+dbServer+":"+port+":"+SID;
    Driver driver = new oracle.jdbc.OracleDriver();
    DriverManager.registerDriver(driver);
    Properties props = new Properties();
   //props.setProperty(OracleConnection.CONNECTION_PROPERTY_THIN_VSESSION_OSUSER,osUser);
    Connection conn = DriverManager.getConnection(url, props);

you must use the jar ojdbc6.jar

at this link: http://docs.oracle.com/cd/E18283_01/java.112/e16548/clntsec.htm

I just need to provide os access for the current computer to this oracle database. A.

+1
source

All Articles