So I have this oracle database hosted on a Linux server. I know how to access it using putty from a windows machine but I need to access it using JDBC from a windows machine. I have the hostname, port, service name, username and password for the database. I don't understand how to open the connection. I tried it like this:
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@hostname/servicename:port:xe",username,password);
but I am unable to connect. Please help
EDIT:
OK I realized that the address was wrong so I changed it to this: Connection con=DriverManager.getConnection("jdbc:oracle:thin:@hostname:port:servicename",username,password);
now it gives the following error : java.sql.SQLEXCEPTION: The listened refused the connection with following error: ORA-12505 TNS:Listener does not currently know of SID given in connect descriptor.
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "dbSchemaName/userName","password");should be through. - instinct