连接到postgres DB时出错

时间:2018-01-10 12:29:42

标签: c# postgresql

打开连接时,出现以下错误:

  

连接未打开。,跟踪:Npgsql.NpgsqlCommand.CheckConnectionState()\ r \ n在Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb)\ r \ n在Npgsql.NpgsqlCommand.ExecuteNonQuery()

以下是使用的代码:

 sil.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

              for (int i = 0 ; i< listDataId.size()  ; i++ ) {

              int all_id = Integer.parseInt(listDataId.get(i));
                String all_names = analiste.get(i);

               mDatabaseHelper.deleteAllName(all_id , all_names);
            }
            isleme.notifyDataSetChanged();


        }
    });

}

在Trace中,我将状态和完整状态设置为0.如何处理此类异常以及它返回的状态? 使用的连接字符串是: Server = 127.0.0.1; port = 5432; Database = abc; User Id = postgres; Password = ****

使用的public void Connect() { if (mConnection == null) { ExceptionHandler(RdbError.InternalError, new Exception("Connection found (NULL) in pool, trying to recreate")); } try { if (mConnection.State != ConnectionState.Open) mConnection.Open(); } catch { ExceptionHandler(RdbError.InternalError, new Exception("Connection could not be opened normally, state was: " + (int)mConnection.State + ", full state: " + (int)mConnection.FullState)); } } 版本为Npgsql.dll

有时连接成功,从长远来看,我得到了上述错误。

0 个答案:

没有答案