0

i have oracle 11g database that is configured to be connected via os authentication with only the alias/tns name of the database and doesn't required username/password.

so i was wondering what is the easiest way to make connection to oracle database with os authentication via java, because i tried 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 simple ways to make this connection.

1 Answer 1

3

I was able to accomplish that with 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

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

all i needed is to give os access for current machine to this oracle database.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.