Try to change localhost
into the hostname or the ip address of your db server. In the example below I have changed into server.remote.net
.
DriverManager.getConnection("jdbc:oracle:thin:@server.remote.net:1521:XE",condb.usrnm,condb.psswrd);
Then pay attention to the port, I assume that your server is listening on port 1521
. Because 1521 is Oracle server the standard port.
After that you have to be sure that there is network connection to your server. There are many ways to do it. As suggested by @YCF_L you could ping the server:
ping server.remote.net
or telnet
telnet server.remote.net 1521
Another important thing you have to pay attention is the XE
keyword in the jdbc connection string. Which is the Oracle instance name. Your remote server can have an Oracle Instance named differently COMPANY_DATA
This means that your connection string could change into:
DriverManager.getConnection("jdbc:oracle:thin:@server.remote.net:1521:COMPANY_DATA",condb.usrnm,condb.psswrd);
On the other hand, on the remote computer there could be a different Database Engine. Like MySql, MS SQL Server, Postgres, etc. In this case the jdbc connection string changes much more.