title: java.sql.SQLRecoverableException: Io error: Invalid number format for port number in ubuntu
body: <p>I am using oracle 11g xe version.So i have established the classpath and went ahead for the program but was facing these errors:</p>
  
  <pre><code>Connecting to database...
      java.sql.SQLRecoverableException: IO Error: Invalid number format for port number
  at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:478)
  at oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:547)
  at oracle.jdbc.driver.T4CConnection.&lt;init&gt;(T4CConnection.java:225)
  at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:29)
  at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:556)
  at java.sql.DriverManager.getConnection(DriverManager.java:571)
  at java.sql.DriverManager.getConnection(DriverManager.java:215)
  at jdbcdisplay.main(jdbcdisplay.java:24)
      Caused by: oracle.net.ns.NetException: Invalid number format for port number
  at oracle.net.resolver.AddrResolution.resolveSimple(AddrResolution.java:497)
  at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:394)
  at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:873)
  at oracle.net.ns.NSProtocol.connect(NSProtocol.java:258)
  at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1577)
  at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:353)
  ... 7 more
  GoodBye!!
  </code></pre>
  
  <p>Now i have not used any IDE's nor is it done in windows.I am trying to connect via linux terminal and all the help that is available is almost for Windows.
  The connection string i am using for the program is:</p>
  
  <pre><code>String jdbcUrl="jdbc:oracle:thin:@localhost:1521/XE:orcl";
  String user="Sourajyoti";
  String password="*******";
  conn=DriverManager.getConnection(jdbcUrl,user,password);
  </code></pre>
  
  <p>The code i am using is as follows:</p>
  
  <pre><code>import java.sql.DriverManager;
  import java.sql.Connection;
  import java.sql.Statement;
  import java.sql.ResultSet;
  import java.sql.Date;
  import java.sql.SQLException;
  
  class jdbcdisplay
  {
  public static void main(String[] args)
  {
      Connection conn=null;
  
      try
      {
          String driver="oracle.jdbc.driver.OracleDriver";
          Class.forName(driver);
  
          System.out.println("Connecting to database...");
          String jdbcUrl="jdbc:oracle:thin:@localhost:1521/XE:orcl";
          String user="Sourajyoti";
          String password="******";
  
          conn=DriverManager.getConnection(jdbcUrl,user,password);
          Statement stmt=conn.createStatement();
          String sql="SELECT ENAME,SALARY,HIREDATE FROM EMP";
          ResultSet rs=stmt.executeQuery(sql);
  
          while (rs.next())
          {
              String name=rs.getString("ENAME");
              double salary=rs.getDouble(2);
              Date date=rs.getDate("HIREDATE");
              System.out.print("Name: "+name);
              System.out.print("Salary: "+salary);
              System.out.println("Hiredate: "+date);
          }
  
          rs.close();
          stmt.close();
          conn.close();
      }
      catch(SQLException se)
      {
          se.printStackTrace();
      }
      catch(Exception e)
      {
          e.printStackTrace();
      }
      finally
      {
          try
          {
              if (conn!=null)
                  conn.close();
          }
          catch(SQLException se)
          {
              se.printStackTrace();
          }
      }
      System.out.println("GoodBye!!");
  }
  }
  </code></pre>