0

Environment: Eclipse(luna)

I am not able to retrive data from the oracle database 11g (11.2.0.2) used jdbe 6

I am getting the following two exception

  1. java.sql.SQLRecoverableException

  2. oracle.net.ns.NetException

Here is the code

import java.sql.*;

public class JavaConnection {

public static void main(String[] args) throws ClassNotFoundException, SQLException {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection  con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","******","*******");
Statement st=con.createStatement();
String sql="select * from emp";
ResultSet rs=st.executeQuery(sql);
while(rs.next())
        System.out.println(rs.getInt(1)+" "+rs.getString(2));
con.close();

}
}

the exception thrown is

Exception in thread "main" java.sql.SQLRecoverableException: IO Error: Got minus one from a read call

at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:489) at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:553) at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:254) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at emodatabase.JavaConnection.main(JavaConnection.java:9)

Caused by: oracle.net.ns.NetException: Got minus one from a read call

at oracle.net.ns.Packet.receive(Packet.java:311) at oracle.net.ns.NSProtocol.connect(NSProtocol.java:300) at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1140) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:340) ... 7 more

What is cause that is causing it and how to resolve it?

Additional Information about listner enter image description here

Sandeep
  • 455
  • 4
  • 26
  • 1
    Are you really sure the port number should be 8080, not, say 1521? You might be confusing the web interface with the listener. Check which address and port your listener is actually on (`lsnrctl status`), and also that there is no firewall blocking access to the port. And that you should be using a SID rather than service name, though that would get a nicer error. Can you connect through SQL\*Plus or SQL Developer with the same details? – Alex Poole Oct 05 '16 at 10:36
  • I tried both but same result – Sandeep Oct 05 '16 at 10:37
  • It sounds as if you are using an old/outdated JDBC driver. Maybe one that was intended for Oracle 8 or 9. Check the `MANIFEST.MF` inside the driver's jar file to get the driver version. Or run `java -jar ojdbc7.jar` to see the version –  Oct 05 '16 at 12:09
  • May help : http://stackoverflow.com/questions/19660336/how-to-approach-a-got-minus-one-from-a-read-call-error-when-connecting-to-an-a/19661592#19661592 – Val Bonn Oct 05 '16 at 12:13

0 Answers0