title: Why oracle driver is needed in Eclipse build path?
body: <p>I am new to JDBC and just made my first program in Eclipse. I am using Oracle 11g XE as database. I have added <code>ojdbc6.jar</code> to my classpath by copying it in the lib folder of the jdk installation. This is my code:</p>
  
  <pre><code>import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.sql.Statement;
  
  public class Test {
  
  /**
   * @param args
   */
  
  String url = "jdbc:oracle:thin:@Voldemort:1521:XE";
  String username = "surender";
  String password = "oracle";
  Statement stmt;
  String query;
  
  public static void main(String[] args) {
      // TODO Auto-generated method stub
      new Test().work();
  
  }
  
  void work() {
      try {
          Connection conn = DriverManager.getConnection(url, username, password);
          stmt = conn.createStatement();
          query = "SELECT * FROM employees";
          ResultSet rset = stmt.executeQuery(query);
          while(rset.next()) {
              System.out.println(rset.getInt(1) + " " + rset.getString(2) + " " + rset.getString(3) + " " + rset.getString(4));
          }
      }
      catch(SQLException se) {
          System.out.println("Exception!!");
          se.printStackTrace();
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Now for some reason it doesn't works in the eclipse nor when I run it outside the IDE through the command prompt (I am on windows 7). But when I added the <code>ojdbc6.jar</code> to the project build path in eclipse it runs fine in the eclipse but as expected still doesn't works from the prompt.</p>
  
  <p>I followed a few tutorials on the net and they all mention that the driver files are needed to be added to the classpath but nothing else. (i added <code>ojdbc6.jar</code> to the buildpath just on a whim, kind of like kiss and tell :p).</p>
  
  <p>Now, why is this? </p>
  
  <p>What kind of resources are needed to be added in the build path?</p>
  
  <p>What if I wanted to run my project outside the IDE, how would i do that?</p>
  
  <p>Thanx in advance!</p>