java.sql.SQLException: Io exception: Got minus one from a read call during JDBC connection with oracle

后端 未结 7 1169
故里飘歌
故里飘歌 2020-12-19 07:52

Hi I am new to java when I tried to connect oracle with my java sample code I got the above exception

My Code is

import java.sql.*;
import java.io.IO         


        
7条回答
  •  温柔的废话
    2020-12-19 08:37

    This is occur due to wrong connectivity with database connection.
    In your program you write 
    Connection con = DriverManager.getConnection
                      ("jdbc:oracle:thin:@localhost:8080:orcl", "system","tiger");
    
    Go to D:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN\tnsnames.ora
    

    Here you find the file like this:

    **abcd** =
         (DESCRIPTION =
            (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = **1521**))
               (CONNECT_DATA =
                (SERVER = DEDICATED)
                (SERVICE_NAME = abcd)
            )
         ) 
    

    Now you write your connection as follow:

      ("jdbc:oracle:thin:@localhost:1521:abcd","your_db_name","your_password")  
    

    After this you don't get the exception.

提交回复
热议问题