title: Can't connect to Oracle 11g via JDBC
body: <p>I am trying to connect my JSF application to my Oracle 11g database.  A while back I had a JSF application connecting a similar way with a Derby database.  Around the same time I was able to connect to an Oracle 11g database via a Java program I wrote.</p>
  
  <p>I've tried to port the code into this recent project, and while everything looks correct, my connection in the code is returning null.</p>
  
  <p>To further this issue, NetBeans seems to lock up when I try to debug.  I'm assuming it goes to use the port that is running GlassFish 4, but somehow can't tell its occupied.</p>
  
  <p>Any help is appreciated; please let me know if I can provide further information that I somehow overlooked.</p>
  
  <p>Code snippets as follows:</p>
  
  <pre><code>@ManagedBean(name="OracleBean")
  @RequestScoped
  public class OracleBean {
  
      private String driver = "oracle.jdbc.driver.OracleDriver";
      private String url = "jdbc:oracle:thin:@localhost:8081:xe";
      private String dbName = "test";
      private String dbUsername = "Username";
      private String dbPassword = "password";
      private Connection connect = null;
  
      private OracleMethods Method;
  
      /**
       * Creates a new instance of DataBean
       */
      public OracleBean() {
          driver = "oracle.jdbc.driver.OracleDriver";
          url = "jdbc:oracle:thin:@localhost:8081:xe";
          dbName = "Test";
          dbUsername = "Username";
          dbPassword = "password";
          connect = null;
  
          Method = new OracleMethods();
      }
  
      public String getColorData(String rowID, int col) {
          connect = Method.getConnection(driver, url, dbName, dbUsername, dbPassword);
  
          if (connect == null) {
              return "SQL Error";
          }
  </code></pre>
  
  <p>//end Bean code</p>
  
  <pre><code>public class OracleMethods extends JPanel {
  
      private Connection connect = null;
  
      public OracleMethods() {}
  
      public Connection getConnection(String driver, String url, String dbName, String dbUsername, String dbPassword) {
          try {
              Class.forName(driver).newInstance();
              connect = DriverManager.getConnection((url + dbName), dbUsername, dbPassword);
          } catch (Exception lex) {
              lex.printStackTrace();
          }
          return connect;
      }
  </code></pre>