title: can't connect to remote oracle database with JDBC
body: <p>I seem to be able to connect to the (<strong>remote</strong>) oracle database using the <em>Run SQL command line</em> but not using JDBC. 
  So, let's say the server name is <em>srv_oracle_prod</em> and the database name is <em>bdcompany.company</em>. In SQL command line I can connect using : </p>
  
  <pre><code>connect user/password@srv_oracle_prod:1521/bdcompany.company
  </code></pre>
  
  <p>But when I try </p>
  
  <pre><code>public class TestRealDatabase {
  
  public static void main(String[] args) {
  
  
      try {
          Class.forName("oracle.jdbc.driver.OracleDriver");
          con = DriverManager.getConnection("jdbc:oracle:thin:srv_oracle_prod:1521/bdcompany.company", 
                  "user", 
                  "password");
      } catch (ClassNotFoundException e) {
          e.printStackTrace();
      } catch (SQLException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      }
  }
  </code></pre>
  
  <p>I get this error in eclipse :</p>
  
  <pre><code>java.sql.SQLException: Listener refused the connection with the following error:
  ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
  
  
  at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:419)
  at oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:536)
  at oracle.jdbc.driver.T4CConnection.&lt;init&gt;(T4CConnection.java:228)
  at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
  at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
  at java.sql.DriverManager.getConnection(Unknown Source)
  at java.sql.DriverManager.getConnection(Unknown Source)
  at theOpenTutorials.TestRealDatabase.main(TestRealDatabase.java:22)
  Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
  ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
  
  
  at oracle.net.ns.NSProtocol.connect(NSProtocol.java:386)
  at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1054)
  at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:308)
  ... 7 more
  </code></pre>
  
  <p>I searched quite a bit but can't find any solution and I am quite the noobie using Oracle.</p>
  
  <p>This is <strong>my</strong> <em>tnsnames.ora</em> file as requested : </p>
  
  <pre><code>XE =
  
        (DESCRIPTION =
          (ADDRESS = (PROTOCOL = TCP)(HOST = PC-HP-08.COMPANY.local)(PORT = 1521))
          (CONNECT_DATA =
            (SERVER = DEDICATED)
            (SERVICE_NAME = XE)
          )
        )
  
      EXTPROC_CONNECTION_DATA =
        (DESCRIPTION =
          (ADDRESS_LIST =
            (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
          )
          (CONNECT_DATA =
            (SID = PLSExtProc)
            (PRESENTATION = RO)
          )
        )
  
      ORACLR_CONNECTION_DATA = 
        (DESCRIPTION = 
          (ADDRESS_LIST = 
            (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1)) 
          ) 
          (CONNECT_DATA = 
            (SID = CLRExtProc) 
            (PRESENTATION = RO) 
          ) 
        ) 
  </code></pre>