JDBC connection can't be created due to exception "ORA-15000: command disallowed by current instance type" when one java client try to connect Oracle ASM instance via JDBC string.
jdbc:oracle:thin:@(DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=<ASM_HOST>)(PORT=<PORT>)) (CONNECT_DATA= (SERVICE_NAME=<ASM_SERVICE_NAME>) ) )
Exception in thread "main" java .sql.SQLException: ORA-15000: command disallowed by current instance type at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:494) at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:441) at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:436) at oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:546) at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:623) at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:252) at oracle.jdbc.driver.T4CTTIoauthenticate.doOSESSKEY(T4CTTIoauthenticate.java:519) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:615)
ASM instance connection required "/as sysdba"
The asm instance does not have a data file, so the user's password will only be stored in the password file. When connecting to asm, user must connect through a password file, and the password file connection must specify its system role ("/as sysdba")
Please refer below sample code to setup "/as sysdba" when creating JDBC connection to ASM instance.
import java.sql.*; import oracle.jdbc.*; import oracle.jdbc.pool.*; // create one DataSource object OracleDataSource ods = new OracleDataSource(); // setup 3 DB properties: user, password and sysdba java.util.Properties prop = new java.util.Properties(); prop.put("user", "sys"); prop.put("password", ""); prop.put("internal_logon", "sysdba"); ods.setConnectionProperties(prop); // setup jdbc URL String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=asm.host.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=+ASM)))"; ods.setURL(url); // create connection Connection conn = ods.getConnection();