title: JavaEE Servlet Oracle connection
body: <p>I try to connect my JavaEE to the Oracle database. If I test the connection from any IDE like DBeaver or from a command prompt there is no problem. I use Eclipse for IDE and Windows 10 for OS. What I tried?</p>
  <pre><code>Class.forName(&quot;oracle.jdbc.driver.OracleDriver&quot;); 
  con = DriverManager.getConnection(&quot;jdbc:oracle:thin:@localhost:1521:xe&quot;,&quot;system&quot;,&quot;password&quot;);
  Class.forName(&quot;oracle.jdbc.driver.OracleDriver&quot;); 
  con=DriverManager.getConnection(&quot;jdbc:oracle:thin:@localhost:1521/xe&quot;,&quot;system&quot;,&quot;password&quot;);
  Class.forName(&quot;oracle.jdbc.driver.OracleDriver&quot;); 
  con=DriverManager.getConnection(&quot;jdbc:oracle:thin:@localhost:1521:XE&quot;,&quot;system&quot;,&quot;password&quot;);
  
  Class.forName(&quot;oracle.jdbc.driver.OracleDriver&quot;); 
  con=DriverManager.getConnection(&quot;jdbc:oracle:thin:@localhost:1521:orcl&quot;,&quot;system&quot;,&quot;password&quot;);
  </code></pre>
  <p>I changed ojdbc14 to ojdbc6
  I changed drivers and tried to connect to different databases SQL Server and MySql but always throws an exception on Class.forName java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
  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 The Connection descriptor used by the client was: localhost:1521:xe<a href="https://i.stack.imgur.com/sS3sG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sS3sG.jpg" alt="enter image description here" /></a></p>