1. Configuring Monitoring
This assumes that the CDB database named Orcl,pdb is under the CDB name PDBORCL
Listener.ora Add (#后面为注释, do not add in)
Sid_list_listener = (sid_list = ( Sid_desc = (global_dbname = ORCL) (sid_name = ORCL) #这里是SID名 ) (Sid_desc = (Global_dbname = PDBORCL) #这里是PDB数据库名 (sid_name = ORCL) #这里是SID名 ) )
Tnsname.ora add
Pdborcl= (DESCRIPTION = ( address_list = ( ADDRESS = (PROTOCOL = TCP) (HOST = localhost) (PORT =1521)) ) (Connect_data = (service_name = PDBORCL) #这里是PDB数据库名 ) )
2. Restart monitoring (requires Administrator privileges)
Lsnrctl Reload
Restart monitoring can also be used with the following code:
Stop listening
Lsnrctl stop
Start monitoring
Lsnrctl start
3. Check the JDBC code
Note: When you connect the PDB, the 1521 port number is not followed by a colon:, but a slash/
For example
String url = "JDBC:ORACLE:THIN:@//LOCALHOST:1521/PDBORCL";
Oracle 12c JDBC Way to connect to the PDB database