Today, when I am developing a project about **, I am using PLSQL to connect to Oracle. However, in Myeclipse DB's attempt, the url I have been using is the following code:
- Jdbc: oracle: thin:127. 0.0.1:1521: Jdbh
The following error message always appears:
- Java. SQL. SQLException: Listener refused the connection with the following error:
- <Span style ="Color: # ff0000 ;"> ORA-12505, TNS: listener does not currently know of SID given in connect descriptor
- TheConnection descriptor used by the client was:
- Localhost:1521: Jdbh
- </Span>
- Atoracle. jdbc. driver. DatabaseError. throwSqlException (DatabaseError. java:124)
- Atoracle. jdbc. driver. DatabaseError. throwSqlException (DatabaseError. java:279)
- Atoracle. jdbc. driver. T4CConnection. logon (T4CConnection. java:318)
- Atoracle. jdbc. driver. PhysicalConnection. <init> (PhysicalConnection. java:343)
- Atoracle. jdbc. driver. T4CConnection. <init> (T4CConnection. java:147)
- At oracle. jdbc. driver. T4CDriverExtension. getConnection (T4CDriverExtension. java:31)
- Atoracle. jdbc. driver. OracleDriver. connect (OracleDriver. java:545)
- Atjava. SQL. DriverManager. getConnection (Unknown Source)
- Atjava. SQL. DriverManager. getConnection (Unknown Source)
- At cn.com. db. DBAccess. getConnection (DBAccess. java:33)
- At cn.com. db. DBAccess. main (DBAccess. java:95)
I have read some materials on the Internet and have not mentioned the specific solution. My personal summary is as follows:
Solution:
Open the tnsnames. ora file in the path D: \ oracle \ product \ 10.2.0 \ db_1 \ NETWORK \ ADMIN to view the following code:
- # Tnsnames. ora Network Configuration File: D: \ oracle \ product \10.2.0\ Db_1 \ network \ admin \ tnsnames. ora
- # Generated by Oracle configuration tools.
- ORCL =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP) (HOST = RedArmychen-PC) (PORT =1521))
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- <Span style ="Color: # ff0000 ;"> (SERVICE_NAME = orcl)
- </Span>)
- )
- EXTPROC_CONNECTION_DATA =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC1 ))
- )
- (CONNECT_DATA =
- (SID = PLSExtProc)
- (PRESENTATION = RO)
- )
- )
Do you see my standard red font?(SERVICE_NAME = orcl)Then you only need to modify the connection URL:
- Jdbc: oracle: thin:127. 0.0.1:1521: Orcl
The problem can be solved. This is only a solution for personal errors! If there are any exceptions, please be patient.