Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection to Oracle without a username or password

Oracle has this concept of allowing database users to be identified by the operating system user who is running the program that is connecting to Oracle. See here.

This allows you to do, as that user on a unix machine for example, a command such as:

sqlplus /

I am attempting to write a Java program for Oracle 10.2 which connects without a username or password. The obvious choice of url:

jdbc:oracle:thin:/@localhost:1521:MYDBSID

doesn't work, giving an error (Sorry I don't have the error available right now).

I have attempted many other forms of doing this as well, but with no luck.

Does anyone have any suggestions on how I can connect a Java program to Oracle using the OS identification method?

like image 710
Jamie Love Avatar asked Oct 17 '08 05:10

Jamie Love


People also ask

How can I connect to database without password?

The user can connect from the operating system level to a database by using just a “/” in place of the username/password string. The user does not have to type his username or password to gain access to the database.


1 Answers

The JDBC Thin driver is a 100% pure Java implementation that cannot collect the needed information from the operating system.

The JDBC OCI driver can do this! Use jdbc:oracle:oci8:/@MYDBSID, it will require that the Oracle driver be installed on that machine, not a problem if this is a server (and is faster to boot and supports many more features than the thin driver)

like image 117
Tony BenBrahim Avatar answered Oct 05 '22 22:10

Tony BenBrahim