I installed Oracle on computer1 and I create a data base named DataBase1 and a user named User1 identified by password1, the ip adress of that computer is 1.1.1.1
我在computer1上安装了Oracle,我创建了一个名为DataBase1的数据库和一个名为User1的用户,该用户由password1识别,该计算机的ip地址是1.1.1.1
I connected that computer to a second one (computer2) that the ip address is 1.1.1.2.
我将该计算机连接到第二个(计算机2),IP地址是1.1.1.2。
I created a java program who can connect to the data base by specifying User1 and password1 and there is not a problem when I run it in computer1
我创建了一个java程序,可以通过指定User1和password1连接到数据库,当我在computer1中运行它时没有问题
how can I specify the user name from computer2 to connect to the same data base?
如何从computer2指定用户名以连接到同一数据库?
I tried some thing like "1.1.1.1/user1" , "http://1.1.1.1:8888/user1" but I can not connect...
我试过像“1.1.1.1/user1”,“http://1.1.1.1:8888/user1”这样的东西,但我无法连接......
thank you.
1 个解决方案
#1
You can connect to Oracle database in network using below command; provided sqlplus is included in path:
您可以使用以下命令连接到网络中的Oracle数据库;提供的sqlplus包含在路径中:
sqlplus User1/password1@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=1.1.1.1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=DataBase1)))
PFB java program to connect Oracle database in your network:
PFB java程序连接网络中的Oracle数据库:
import java.sql.*;
class OracleConnect{
public static void main(String args[]){
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@1.1.1.1:1521:DataBase1","User1","password1");
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select 1 from dual");
.
.
conn.close();
}catch(Exception ex){ System.out.println(ex);}
}
}
Try both options from computer2 and share error if any.
尝试使用computer2中的两个选项并分享错误(如果有)。
#1
You can connect to Oracle database in network using below command; provided sqlplus is included in path:
您可以使用以下命令连接到网络中的Oracle数据库;提供的sqlplus包含在路径中:
sqlplus User1/password1@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=1.1.1.1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=DataBase1)))
PFB java program to connect Oracle database in your network:
PFB java程序连接网络中的Oracle数据库:
import java.sql.*;
class OracleConnect{
public static void main(String args[]){
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@1.1.1.1:1521:DataBase1","User1","password1");
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select 1 from dual");
.
.
conn.close();
}catch(Exception ex){ System.out.println(ex);}
}
}
Try both options from computer2 and share error if any.
尝试使用computer2中的两个选项并分享错误(如果有)。