What database version are you using?
What OS do you have?
Did you trace your connection/path?
( tnsping and/or trcroute , see: Establishing a Network and Testing the Connection)
What is the status of the listener?
My tnsname and host file are well configured but in spite of that, I still get the error ORA-12545 randomly.
Has anyone already encounter the same problem?
Random error possibly means that the Listener gives a redirect to your OCI driver, and your platform cannot use/follow the redirect.
E.g. you connect to Listener on serverA using port 1521, requesting a db connection to service1. The Listener does some form of load balancing, and decides that serverC is best to service service1, and sends a redirect you to connect to serverC on port 1527. Your platform cannot resolve the serverC hostname. Or access to that IP address fails (routing or firewalled). Or port 1527 is by default closed by the firewall.
Enable SQL*Net tracing (via sqlnet,ora) on the client.
Or, list services on Listener you are connecting to and determine just where else (other Listeners, RAC typically) that service is also supported. Build a definitive list of IP addresses and hostnames from this. On your client platform, ensure hostname resolution works, IPs are accessible, and ports are not firewalled.
Your question would have been better suited to the General Questions forum, as it's nothing to do with SQL or PL/SQL. Please ensure you post in the correct forum in future, as this also means that you'll target the correct audience and likely receive better support (not that the support you've already got here isn't good hehe!)
Even that, the problem occures again.
This is my sql.net file:
SQLNET.AUTHENTICATION_SERVICES = (NTS)
DIAG_ADR_ENABLED = OFF
TRACE_LEVEL_CLIENT = admin
TRACE_DIRECTORY_CLIENT = D:\oracle\product\10.2.0\client_1\NETWORK\trace
TRACE_UNIQUE_CLIENT = ON
And this is my tnsname:
(ADDRESS = (PROTOCOL = TCP)(HOST = ol6Banks)(PORT = 1521))
(LOAD_BALANCE = YES)
(SERVER = SHARED)
(SERVICE_NAME = DB11G)