I was put in charge of migrating our software from native ODP.NET to the managed ODP.NET, all parts of the software are now using the managed client and functioning properly so far.
The problem is in one method, we're getting a document from the database (DbType Blob) by executing a stored procedure, when I try to access the value of the output parameter (type OracleBlob) it throws this exception:
{"ORA-12571: TNS:packet writer failure"}
Oracle.ManagedDataAccess.Client.OracleException: 'ORA-12537: TNS:connection closed
https://docs.oracle.com/error-help/db/ora-12537/'
This wasn't an issue with the native odp.net. The connection and command are set up correctly. There are other OracleBlob member fields that throw an exception like IsEmpty
, Length
, ReadTimeout
.
This is my code, maybe I'm missing something:
public byte[] GetDocumentContent(long id)
{
byte[] result = null;
OracleBlob blob = null;
OracleParameter blobImage;
using (OracleConnection con = new OracleConnection(_conString))
{
con.Open();
using (OracleCommand cmd = new OracleCommand("get_document_content", con))
{
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.Add("p_document_content_id", OracleDbType.Int64, ParameterDirection.Input).Value = id;
blobImage = cmd.Parameters.Add("p_document_image", OracleDbType.Blob);
blobImage.Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
if (((OracleBlob)blobImage.Value).IsNull == false)
{
blob = (OracleBlob)blobImage.Value;
result = blob.Value;
}
}
con.Close();
}
return result;
}