![](/img/trans.png)
[英]How to set connection for my java program(standalone using jdk no netbeans) with oracle 10g database by creating datasource?
[英]Remote Oracle database connection using java(netbeans)
这是我用于连接个人计算机上的Oracle数据库的代码:
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection co = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:etecsa", "system", "asd");
它可以工作,但是如果我将localhost更改为IP,它将无法连接到数据库。 我已经停用了防火墙,但是什么也没有。
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection co = DriverManager.getConnection("jdbc:oracle:thin:10.8.6.50:1521:etecsa", "system", "asd");
在哪里可以配置oracle数据库以接受来自特定ip的连接,而不仅限于本地主机?
jdbc:oracle:driver_type:[用户名/密码] @database_specifier
因此,在您的情况下(如果etecsa是SID
),则URL为@host:port:SID
jdbc:oracle:thin:@10.8.6.50:1521:etecsa
如果etecsa是服务名称,则使用@//host:port/service_name
jdbc:oracle:thin:@//10.8.6.50:1521/etecsa
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.