Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"ORA-01012" error message when trying to connect to an Oracle database

Using C# and Oracle Data Provider for .NET (ODP) I made a long query to the database, then I end the connection on the server side using TOAD. After that, the subsequent calls to the database, even creating a new OracleConnection object, throw the following error:

ORA-01012: not logged on
Process ID: xxx
Session ID: yyy Serial number: zzz

Where Process ID and Session ID are the identifiers I used to end the connection.

It seems like when I end the connection to the Oracle database on the server side, the broken connection is returned to the connection pool. And when the C# client code (using ODP) opens a new connection, the broken connection that was returned to the connection pool may be retrieved.

Any ideas on how to fix this behaviour?

BTW I'm using Oracle client 10

like image 933
Juan M. Elosegui Avatar asked Jun 13 '12 19:06

Juan M. Elosegui


People also ask

How do I fix Ora 01012?

ORA-01012: not logged on error while trying to start the oracle database. Solution: To resolve this error remove the orphaned shared memory segment using sysresv utility. sysresv command will list the currently allocated IPC resources for shared memory and remove the shared memory segment using ipcrm -m command.

What is the cause of an ORA error message?

This error is often caused by typos, maybe in your connection string, but possibly in your tnsnames. ora file. It is also possible that the tnsnames. ora file is not accessible or does not even exist.

How do I resolve ORA 00604 error?

Find the trigger that is causing the problem and disable it or drop it to resolve the issue. Usually, this error occurs in the Oracle database by the system level triggers on DDL or SYSTEM events. Another example of error ORA-00604 is when the user attempts to run a newly-created table using SELECT* from cdc.

How do I fix Ora 01078 failure in processing system parameters?

The ORA-01078 error is frequently thrown when you put comments on your initialization parameter file (pfile). Removing the comments (denoted with the # character) from your pfile will often fix the ORA-01078 error.


1 Answers

I solved my problem by setting to true the "Validate Connection" property in the connection string.

you can read more here

As a warning I quote the Oracle docs.

The Validate Connection attribute validates connections coming out of the pool. This attribute should only be used when absolutely necessary because it causes a server round-trip to the database to validate each connection right before it is provided to the application. If invalid connections are uncommon, developers can create their own event handler to retrieve a new connection, rather than using Validate Connection. This generally provides better performance.

like image 186
Juan M. Elosegui Avatar answered Sep 19 '22 15:09

Juan M. Elosegui