Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

sandeep.cNov 5 2013 — edited Nov 5 2013

Hello Everybody,.

I would like to know,what am I missing here...

I have the following Java code

/**

     * Connect to Oracle Database.

     */

    private static void oracleConnect() {

        Connection conn = null;

        try {

            //Class.forName("oracle.jdbc.driver.OracleDriver");

            conn = DriverManager.getConnection(

                    "jdbc:oracle:thin:@localhost:1521:orcl", "scott",

                    "Scott123");

            System.out.println("Connected to the Oracle database...");

        } /*catch (ClassNotFoundException e) {

            e.printStackTrace();

        } */catch (SQLException e) {

            e.printStackTrace();

        } finally {

            try {

                conn.close();

                System.out.println("Connection closed...");

            } catch (SQLException e) {

                e.printStackTrace();

            }

        }

    }

Exception:

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

    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:412)

    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:531)

    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:221)

    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)

    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503)

    at java.sql.DriverManager.getConnection(Unknown Source)

    at java.sql.DriverManager.getConnection(Unknown Source)

    at com.facebook.www.javagroup.GenericTaskInterpreter.oracleConnect(GenericTaskInterpreter.java:53)

    at com.facebook.www.javagroup.GenericTaskInterpreter.main(GenericTaskInterpreter.java:27)

Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:

ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

All my oracle services are running fine and I am also able to login as user scott.My Oracle version is: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

Any help would be appreciated.Thanks in advance.

Comments

Mr Peabody-Oracle

There might be some caveats because you did not specify what version of Documaker you are using. The initialization of DAL functionality is sufficient in later versions - say 12.5 on - but it is possible this might not work in some really old versions.

In your INI, under the TRN_FIELDS group, comment out the RUNDATE definition by placing a semicolon at the start. (This way you will be able to reverse it if this doesn't work.)

pastedImage_0.png

Next, look for - or add - the GenTrnDummyFields group.

pastedImage_1.png

This group is used to pre-initialize any GVM variables that you want set at the transaction level, but not necessarily coming from the extract. You see in this example, mine is setting the variables ONE, TWO, and now RUNDATE.

The definition expects to have a constant definition, but through the wizardry of INI built-in functions, you can call a DAL script that actually returns the value. The ~DalRun is a built-in that executes the named script that follows. Whatever that script returns becomes the value assigned into the RUNDATE GVM when the transaction begins. In my case, I called the script "adate" and therefore would be assumed "adate.dal" and be a standard resource.

The script can do whatever it wants to determine the date, but I think you want to have it return in the YYYYMMDD format.

User_QGE9P

I was able to call a DAL doing it this way but I had to hardcode a date to get it to work.

Is there anyway that the DAL can look at values in the extract file to determine how the date should be set.

I need to look at other trn_fields or other values in the extract file to determine the date.

This is documaker 12.6 Standard Edition running 3 steps.

Just let me know if this is possible.

Mr Peabody-Oracle
Answer

There is a caveat, but yes, you should be able to use DAL to query other data and information. The caveat is that this assignment occurs at the start of a transaction, so the question is whether the information you are seeking has been loaded and is available yet.

I'm pretty sure that the GentrnDummyFields are assigned after the TRN_FIELDS. That being the case, you should be able to use DAL to query those GVMs. Since you are talking about the 3-step process - GenTrn, Gendata, and GenPrint - I might question whether the rest of your extract rows are loaded at the point where  you need. You would have to determine this by using the GetData or SrchData functions from DAL to do your queries.

Marked as Answer by User_QGE9P · Sep 27 2020
3255688

Below works for us. Can you do this.

< TRN_FIELDS >

RunDate = !/xpath/to/my/rundate

Mr Peabody-Oracle

That would be the traditional way to map the RunDate - assuming you are using an XML extract. The question was whether you could call DAL to determine the Rundate in some other way than direct mapping in TRN_FIELDS.

1 - 5
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 3 2013
Added on Nov 5 2013
13 comments
14,767 views