0

I have two computers on one network. I have entered the ip of another computer, it works fine in the browser, but when using this ip on java I found the database connected to my localhost database not from the other computer!

my code jdbc

  public Connection MakeConnect() throws ClassNotFoundException, SQLException{

    Class.forName("oracle.jdbc.driver.OracleDriver");

Connection connection =  DriverManager.getConnection(
            "jdbc:oracle:thin:http://192.168.1.109:5560/isqlplus", "school",
            "sch"); // first : user(hr) second pass(hr) .!

   return connection ; // return connetion of database 
Thomash
  • 6,339
  • 1
  • 30
  • 50
hesham
  • 33
  • 1
  • 11

4 Answers4

1

I think your JDBC connection string may be in a wrong format. You should provide this in the following way:

jdbc:oracle:thin:@[HOST][:PORT]:SID
jdbc:oracle:thin:@//[HOST][:PORT]/SERVICE

Instead it looks you specified ISQLPLus link. I haven't tested it but my guts say me it is the reason. I think in your case it should be something like that:

jdbc:oracle:thin:@192.168.1.109/SERVICEorSID

And you have to find the service name by yourself. In a generic case it is a name of the database. By default it is usually set to ORCL but possibly you set it to another name.

Make sure you read a following document: http://www.orafaq.com/wiki/JDBC

SQ9MCP
  • 66
  • 1
  • 5
0

If the connection succeeds without error and if this 192.168.1.109 ip address is not of your local machine then it must connect to some other machine.

What made you think it's connecting to the local DB instance?

Thihara
  • 7,031
  • 2
  • 29
  • 56
  • i have tested many quries and found all getting data from my old or local database not from anouther computer ! – hesham May 27 '13 at 06:08
  • Then clean and compile the code. Since you have hard coded the URL it may occur if some old compiled class is being used. – Thihara May 27 '13 at 06:10
  • i have cleaned all my projects but still reading from old database – hesham May 27 '13 at 06:20
0

Check firewall settings of the other computer. Sometimes it may not allows for the external connections

0

If you want to allow a specific client ip-address (for example: 192.168.1.4) to access the mysql database running on a server, you should execute the following command on the server that is running the mysql database.

    $ mysql -u root -p
    Enter password:
    mysql> use mysql
    mysql> GRANT ALL ON *.* to root@'192.168.1.4' IDENTIFIED BY 'your-root-password'; 
    mysql> FLUSH PRIVILEGES;

Also, update firewall rules to make sure port# 3306 is open on the server that is running the mysql database.

user2365199
  • 29
  • 1
  • 8