how to resolve Got minus one from a read call in oracle 11g jdbc 7/14 jdk 1.7?

前端 未结 4 1510
旧巷少年郎
旧巷少年郎 2021-01-20 08:44

I am using netbeans and jdk 7 updt 9 with 1.7 and following is my code.

public class jd {
    public static void main(String[] args) throws ClassNotFoundExcep         


        
4条回答
  •  伪装坚强ぢ
    2021-01-20 09:28

    I think the error is in the port number 1158 in this line:

        Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1158:ORCL","system", "system");
    

    Normally you connect to an Oracle database using port 1521. Try replacing 1158 with 1521.

    Your database may be running the Enterprise Manager on port 1158. That's a web application that you access, often by navigating to https://localhost:1158/em. The Oracle database itself will typically be listening on port 1521.

    When using JDBC you need to connect direct to the database, not to some web application instead. The Oracle JDBC driver understands the proprietary binary protocol it uses to communicate with the database, but it doesn't understand the HTTP it gets back from the Enterprise Manager web application. Hence you get an odd network error. You can expect similar random network errors if you attempt to connect the JDBC driver to something else that isn't an Oracle database either.

提交回复
热议问题