Oracle错误:ORA-12541:TNS:没有监听器

时间:2015-08-13 20:50:02

标签: c# winforms oracle oracle11g

我正在使用VS2013和oracle 11g作为数据库。 Oracle开发人员套件10g也安装在我的机器上。我正在尝试使用

连接我的数据库
public void connect()
    {
        try
        {

            conString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=" + "(ADDRESS=(PROTOCOL=" + txtBoxProcol.Text + ")(HOST=" + txtBoxHost.Text + ")(PORT=" + txtBoxPort.Text + ")))" + "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" + txtBoxDSource.Text + ")));" + "User Id=" + txtBoxUsr.Text + ";Password=" + txtBoxPaswrd.Text + "enlist=false; pooling=false;";
            con = new OracleConnection();
            con.ConnectionString = conString;
            con.Open();
            MessageBox.Show("Connected Successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        catch (OracleException ex) // catches only Oracle errors
        {
            switch (ex.Number)
            {
                case 1:
                    MessageBox.Show("Error attempting to insert duplicate data.");
                    break;
                case 12545:
                    MessageBox.Show("The database is unavailable.");
                    break;
                default:
                    MessageBox.Show("Database error: " + ex.Message.ToString());
                    break;
            }
        }
        finally
        {
            con.Clone();
            con.Dispose();
        }
    }

但我收到了以下错误

Oracle错误:ORA-12541:TNS:没有监听器

将conString更改为

 conString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=" + "(ADDRESS=(PROTOCOL=TCP)(HOST=DESKTOP-3B866TI)(PORT=1521)))" + "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCL)));" + "User Id=scott;Password=tiger;";

也无效。

我的 TNSNAMES.ORA

ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
  (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
  (SID = CLRExtProc)
  (PRESENTATION = RO)
)
)

ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
  (SERVER = DEDICATED)
  (SERVICE_NAME = orcl)
)
)

Listener.ora

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
  (SID_NAME = CLRExtProc)
  (ORACLE_HOME = c:\app\hanna\product\11.2.0\dbhome_1)
  (PROGRAM = extproc)
  (ENVS =      "EXTPROC_DLLS=ONLY:c:\app\hanna\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
(SID_DESC=
(GLOBAL_DBNAME = PLSExtProc)
(ORACLE_HOME = c:\app\hanna\product\11.2.0\dbhome_1)
(SID_NAME = ORCL)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
  (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)

Registry中的Oracle_Home值= C:\ app \ hanna \ product \ 11.2.0 \ dbhome_1 我在cmd中运行lsnrctl stop lsnrctl start命令。但我的联系并不开放。在SQL * PLUS中我的连接正常。

0 个答案:

没有答案