Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9045807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:27:04+00:00 2026-06-16T11:27:04+00:00

Possible Duplicate: Java Oracle localhost connection error (ORA-12505) When I try to connect to

  • 0

Possible Duplicate:
Java Oracle localhost connection error (ORA-12505)

When I try to connect to Oracle 10g Express Edition, it gives me error:

java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
localhost:1521:xe

My sample code:

    Class.forName("oracle.jdbc.OracleDriver");
    Connection connection = null;
    connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "mk119", "mk119");
    Statement stmt = connection.createStatement();

In database:

SQL> connect mk119
Enter password:
Connected.
SQL> ed
Wrote file afiedt.buf

  1* select sys_context('userenv', 'instance_name') from dual
SQL> /

SYS_CONTEXT('USERENV','INSTANCE_NAME')
----------------------------------------------------------------------

xe

SQL>

Please help me on this.

EDIT: Stacktrace:

java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
localhost:1521:xe

        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
        at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
        at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
        at java.sql.DriverManager.getConnection(DriverManager.java:579)
        at java.sql.DriverManager.getConnection(DriverManager.java:221)
        at fingerprint.DatabaseTest.main(DatabaseTest.java:14)

EDIT: Complete Code:

import java.sql.*;

public class DatabaseTest {
    public static void main(String [] args){
        try{
            Class.forName("oracle.jdbc.OracleDriver");
            Connection connection = null;
            connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "mk119", "mk119");
            Statement stmt = connection.createStatement();
            System.out.println("Connection created");
            stmt.close();
            connection.close();
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T11:27:05+00:00Added an answer on June 16, 2026 at 11:27 am

    As per the answer provided here, check the following (answer is the one from the related, maybe duplicate, question):

    “Check if listener.ora file under the \admin\NETWORK directory has the following value:

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

    “

    Therefore check your connection url: host, port, sid, to make sure it is properly set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Java sockets - java.net.ConnectException: Connection refused: connect I've created a simple chat
Possible Duplicate: Java Connecting to remote MySQL database I'm trying to connect to MySQL
Possible Duplicate: Java socket sends some data during connection to server I have two
Possible Duplicate: Java how to: Generic Array creation Error generic array creation I have
Possible Duplicate: How to add a UTF-8 BOM in java My oracle database has
Possible Duplicate: java.net.SocketException: Software caused connection abort: recv failed I'm trying to write a
Possible Duplicate: Java Serial Communication on Windows Friends, I want to connect and transfer
Possible Duplicate: String and Final From http://docs.oracle.com/javase/6/docs/api/java/lang/String.html I can read that: Strings are constant;
Possible Duplicate: SSL handshake alert: unrecognized_name error since upgrade to Java 1.7.0 My J2SE
Possible Duplicate: Java SE 6 vs. JRE 1.6 vs. JDK 1.6 - What do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.