How can I find out the URL and port for an Oracle database?
如何查找Oracle数据库的URL和端口?
Example:
例子:
"jdbc:oracle:thin:@host:port:dbName","userName", "password");
“jdbc:oracle:薄:@host:端口:dbName”、“用户名”,“密码”);
Is there an SQL command or log/configuration file I can look at?
是否有SQL命令或日志/配置文件可以让我查看?
3 个解决方案
#1
34
With oracle, there is a tnsnames.ora
file which defines database addresses. This file is normally found in $ORACLE_HOME/network/admin
and is used by oracle clients like sqlplus or Toad. Here is a sample tns entry:
对于oracle,有一个tnsnames。定义数据库地址的ora文件。这个文件通常在$ORACLE_HOME/network/admin中找到,由sqlplus或Toad等oracle客户端使用。以下是tns条目示例:
ORA11 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORA11)
)
)
From this entry you can work out that your jdbc connection string would be:
通过这个条目,您可以计算出您的jdbc连接字符串将是:
jdbc:oracle:thin:@hostname:1521:ORA11
#2
6
By reading the documentation which came along with the JDBC driver in question.
通过阅读有关JDBC驱动程序的文档。
In case of the Oracle JDBC thin driver, you can find it here.
对于Oracle thin JDBC驱动程序,您可以在这里找到它。
Specifying a Database URL, User Name, and Password
The following signature takes the URL, user name, and password as separate parameters:
以下签名将URL、用户名和密码作为单独的参数:
getConnection(String URL, String user, String password);
Where the URL is of the form:
其URL为:
jdbc:oracle:<drivertype>:@<database>
The following example connects user scott with password tiger to a database with INSTANCE_NAME orcl through port 1521 of host myhost, using the Thin driver.
下面的示例使用瘦驱动程序通过主机myhost的端口1521将用户scott和password tiger连接到具有INSTANCE_NAME orcl的数据库。
Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@myhost:1521:orcl", "scott", "tiger");
If you want to use the default connection for an OCI driver, specify either:
如果要为OCI驱动程序使用默认连接,请指定:
Connection conn = DriverManager.getConnection ("jdbc:oracle:oci:scott/tiger@");
or:
或者:
Connection conn = DriverManager.getConnection ("jdbc:oracle:oci:@", "scott", "tiger");
For all JDBC drivers, you can also specify the database with a Oracle Net keyword-value pair. The Oracle Net keyword-value pair substitutes for the TNSNAMES entry. The following example uses the same parameters as the preceding example, but in the keyword-value format:
对于所有JDBC驱动程序,还可以使用Oracle Net关键字-值对指定数据库。Oracle网络关键字-值对替代了tnsname条目。以下示例使用与前面示例相同的参数,但采用关键字-值格式:
Connection conn = DriverManager.getConnection (jdbc:oracle:oci:@MyHostString","scott","tiger");
or:
或者:
Connection conn = DriverManager.getConnection ("jdbc:oracle:oci:@(description=(address=(host= myhost) (protocol=tcp)(port=1521))(connect_data=(INSTANCE_NAME=orcl)))", "scott", "tiger");
#3
0
The URL is simply the server where it is running.
URL仅仅是它运行的服务器。
If it is running locally, it must be localhost:1521. 1521 is the default port of oracle databases.
如果它在本地运行,那么它必须是localhost:1521。1521是oracle数据库的默认端口。
Take a look for further port reading: http://www.red-database-security.com/whitepaper/oracle_default_ports.html
进一步查看端口读取:http://www.red-database-security.com/whitepaper/oracle_default_ports.html
#1
34
With oracle, there is a tnsnames.ora
file which defines database addresses. This file is normally found in $ORACLE_HOME/network/admin
and is used by oracle clients like sqlplus or Toad. Here is a sample tns entry:
对于oracle,有一个tnsnames。定义数据库地址的ora文件。这个文件通常在$ORACLE_HOME/network/admin中找到,由sqlplus或Toad等oracle客户端使用。以下是tns条目示例:
ORA11 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORA11)
)
)
From this entry you can work out that your jdbc connection string would be:
通过这个条目,您可以计算出您的jdbc连接字符串将是:
jdbc:oracle:thin:@hostname:1521:ORA11
#2
6
By reading the documentation which came along with the JDBC driver in question.
通过阅读有关JDBC驱动程序的文档。
In case of the Oracle JDBC thin driver, you can find it here.
对于Oracle thin JDBC驱动程序,您可以在这里找到它。
Specifying a Database URL, User Name, and Password
The following signature takes the URL, user name, and password as separate parameters:
以下签名将URL、用户名和密码作为单独的参数:
getConnection(String URL, String user, String password);
Where the URL is of the form:
其URL为:
jdbc:oracle:<drivertype>:@<database>
The following example connects user scott with password tiger to a database with INSTANCE_NAME orcl through port 1521 of host myhost, using the Thin driver.
下面的示例使用瘦驱动程序通过主机myhost的端口1521将用户scott和password tiger连接到具有INSTANCE_NAME orcl的数据库。
Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@myhost:1521:orcl", "scott", "tiger");
If you want to use the default connection for an OCI driver, specify either:
如果要为OCI驱动程序使用默认连接,请指定:
Connection conn = DriverManager.getConnection ("jdbc:oracle:oci:scott/tiger@");
or:
或者:
Connection conn = DriverManager.getConnection ("jdbc:oracle:oci:@", "scott", "tiger");
For all JDBC drivers, you can also specify the database with a Oracle Net keyword-value pair. The Oracle Net keyword-value pair substitutes for the TNSNAMES entry. The following example uses the same parameters as the preceding example, but in the keyword-value format:
对于所有JDBC驱动程序,还可以使用Oracle Net关键字-值对指定数据库。Oracle网络关键字-值对替代了tnsname条目。以下示例使用与前面示例相同的参数,但采用关键字-值格式:
Connection conn = DriverManager.getConnection (jdbc:oracle:oci:@MyHostString","scott","tiger");
or:
或者:
Connection conn = DriverManager.getConnection ("jdbc:oracle:oci:@(description=(address=(host= myhost) (protocol=tcp)(port=1521))(connect_data=(INSTANCE_NAME=orcl)))", "scott", "tiger");
#3
0
The URL is simply the server where it is running.
URL仅仅是它运行的服务器。
If it is running locally, it must be localhost:1521. 1521 is the default port of oracle databases.
如果它在本地运行,那么它必须是localhost:1521。1521是oracle数据库的默认端口。
Take a look for further port reading: http://www.red-database-security.com/whitepaper/oracle_default_ports.html
进一步查看端口读取:http://www.red-database-security.com/whitepaper/oracle_default_ports.html