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; try { conn = new OracleConnection( "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myserver.com)(PORT=1521))(CONNECT_DATA=(SID=MySID)));User Id=MyUserId;Password=MyPassword;"); conn.Open(); 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); } finally { if (conn != null) conn.Dispose(); } Console.ReadKey(); |
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.
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.