Recently, we are using C # code to connect Oracle database, which is divided into two parts, client and server of WCF. There is no problem in the startup and running of the program, and there is no problem in the running after it is deployed to the server. But when you visit again the next day, you will throw the exception shown below. What’s going on?
Oracle.DataAccess.Client.OracleException ORA-03135: connection lost contact
Process ID: 22574
Session ID: 799 Serial number: 43225 Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck)
at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)
at Oracle.DataAccess.Client.OracleDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
The relevant code used to connect Oracle database is also very typical, without any complexity.
public DataSet ExcuteDataSetForOralce(string sql, CommandType type, List<OracleParameter> paras)
{
DataSet ds = new DataSet();
OracleCommand cmd = null;
try
{
using (OracleConnection conn = new OracleConnection(ConnectionString))
{
using (cmd = new OracleCommand(sql, conn))
{
if (paras != null)
{
foreach (OracleParameter p in paras)
{
cmd.Parameters.Add(p);
}
}
cmd.CommandType = type;
OracleDataAdapter oda = new OracleDataAdapter();
oda.SelectCommand = cmd;
conn.Open();
oda.Fill(ds, "tempTable");
conn.Close();
}
}
}
catch (Exception ex)
{
log.Error("error", ex, LogType.Error);
}
return ds;
}
Through multi-party search, it is found that this is not a code problem. Moreover, the problem of the connection between the provider and the database. In fact, when we create a new connection, we get the connection from the database connection pool. These connections are placed in the. Net provider. Conn.Close () does not close the connection, but returns it to the connection pool.
Now the problem is Oracle provider, not code. Your program hasn’t interacted with the database for a long time, and the database server turned off the open state of the connection, but the provider didn’t handle it in time, and still gave it to the C # code, so this exception was thrown.
The solution is to directly connect to the database without using the connection pool. Although this problem will not occur, there will be performance loss.
stay app.config In the configuration file of, in the string datasource = ((description…), add do not use connection pool.
Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx)(PORT=1521)))(CONNECT_DATA =(SERVICE_NAME=xxx)(SERVER = DEDICATED)));User ID=xxx;password=xxxxx;Pooling=false;
http://www.csdn.net/topics/3920225524
Read More:
- Solve the problem that the interface between C # WinForm program and Oracle doesn’t respond for a long time
- A series of errors encountered in connecting to the database using Oracle SQL developer
- seaborn.load_ Data set error urlerror: < urlopen error [winerror 10060] the connection attempt failed because the connecting party did not reply correctly after a period of time or the connected host did not respond
- Navicate premium Connecting to a remote Oracle,ORA-12514: TNS:listener does not currently know of service requested in c
- An error is reported when kettle connects Oracle database and MySQL database
- Oracle database file is damaged, Error:ORA-01033 :ORACLE initialization or shutdown in progress
- Failed to create Oracle Oracle home user solution appears in oracle12c installation
- After switching the tidb database, an error could not commit JDBC transaction appears from time to time
- The time of the time database displayed by the front end is inconsistent
- Oracle12c client32 bit installation error: [ins-20802] Oracle net configuration assistant failed
- The solution to the problem that the method of interacting with database in the servlet class is invalid after the servlet submits 404, 500 refresh and becomes 404, and after connecting to the data pool
- When installing oracle12c, the problem of “unable to check whether the specified location is on CFS” appears
- Error connecting to master, – retry time: 60 retries: 86400
- How to Solve mybatis returns null when querying Oracle database with char type field
- 2059 error in connecting to database by Navicat premium
- When SAP receives the goods, the system prompts that it can only be recorded in the period 2009 / 09 and 2009 / 08 of company code 1101
- Solve the problem that TeamViewer software prompts that the trial period has expired and cannot be operated remotely
- Oracle can’t start the database due to deleting DBF file by mistake
- Oracle database missing init.ora Solutions
- Solve the problem of VC 6.0 fatal error C1033: cannot open program database’.\debug\vc60.pdb’