Вопрос

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.

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top