Java-oracle连接异常

时间:2016-10-05 10:34:32

标签: java sql oracle11g

环境:Eclipse(luna)

我无法从使用jdbe 6的oracle数据库11g(11.2.0.2)中检索数据

我收到以下两个例外

  1. java.sql.SQLRecoverableException

  2. oracle.net.ns.NetException

  3. 这是代码

    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();
    
    }
    }
    

    抛出的异常是

      

    线程“main”中的异常 java.sql.SQLRecoverableException :IO错误:从读取调用中减去一个

         

    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:489)       在oracle.jdbc.driver.PhysicalConnection。(PhysicalConnection.java:553)       在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)       在emodatabase.JavaConnection.main(JavaConnection.java:9)

         

    引起: oracle.net.ns.NetException:从读取呼叫中减去一个

         

    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)       在oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:340)       ......还有7个

    造成它的原因是什么以及如何解决它?

    有关listner的其他信息 enter image description here

0 个答案:

没有答案