ORA-01017 invalid username/password; logon denied

I was having some trouble with an java application connecting to a oracle 9i database. The problem was that the application sometimes gave the following error:

ORA-01017: invalid username/password; logon denied

The developer of the application could not find the cause of this error so i started some testing myself. I wrote a simple .net console app to test the connection. It gave the same problems: Sometimes a connection success and sometimes logon denied.

OracleConnection conn = null;
                conn = new OracleConnection(
                "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myserver.com)(PORT=1521))(CONNECT_DATA=(SID=MySID)));User Id=MyUserId;Password=MyPassword;");
                Console.WriteLine(DateTime.Now + ": Connection Success! Version: " + conn.ServerVersion);
            catch (OracleException ex)
                Console.WriteLine(DateTime.Now + ": Oracle Error: " + ex.Message);
            catch (Exception ex)
                Console.WriteLine(DateTime.Now + ": Other Error: " + ex.Message);
                if (conn != null)

After some playing around with the connectionstring i found out that the following string did not give any problems:

"Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyServer.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=MySid)));User Id=MyUserId;Password=MyPassword;"

I changed SID= to SERVICE_NAME= and this solved the problems.

This entry was posted in .net, Oracle. Bookmark the permalink.

1 Response to ORA-01017 invalid username/password; logon denied

  1. Boosa says:

    Great tip even after nearly 5 years. I have also this problem with Oracle 11g and DotConnect from Devart.
    Unfortunately the ORA-01017 stil occur but much less than before. So I have to experiment further.

Leave a Reply

Your email address will not be published.