Connection denied from Java application I try to connect from my little Java class to Oracle11g database and connection was refused with a SQL error.

From client (SQL Developer) connection works.

This is the ERROR when I try to run java class:

java.sql.SQLException: 

ORA-00604: errore riscontrato in SQL ricorsivo livello 1
ORA-20001: Denied!  You are not allowed to logon the database
ORA-06512: a line 19

    at oracle.jdbc.driver.T4CTTIo`enter code here`er.processError(T4CTTIoer.java:447)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:389)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:382)
    at oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:675)
    at oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:448)
    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:513)
    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227)
    at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:383)
    at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:776)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:432)
    at oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:553)
    at oracle.jdbc.driver.T4CConnection.&lt;init&gt;(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(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:247)
    at DBConnection.setDBConnection(DBConnection.java:48)
    at Main.main(Main.java:31)


This is the code of my connection class:

String host = "xxx";
String service = "xxx";
String username = "xxx";
String password = "xxx";


        if(host != null &amp;&amp; username != null &amp;&amp; password != null) {
            // Establishing DB Connection
            try {
                connection = DriverManager.getConnection(
                        "jdbc:oracle:thin:@" + host + ":1521/" + service , username, password);
                ...
Seems like the DBA created a logon trigger that verifies connection on logins. ORA-20001-20999 are custom exceptions defined by the code that throws them, this is an environmental issue, ask the DBA.

If you have the necessary privilegs, you can check the trigger yourself, you can start with:

select * from dba_triggers where triggering_event like 'LOGON%';