Home » Open Source » Programming Interfaces » ORA-28150 when I use proxy user by JDBC , but sqlplus not
ORA-28150 when I use proxy user by JDBC , but sqlplus not [message #459488] Sun, 06 June 2010 02:06 Go to next message
khosravi
Messages: 68
Registered: April 2006
Member
Hello
I have created a proxy user when i use it in sqlplus it's OK but when I use it in JDBC i get ORA-28150

please let me to explain what I am doing , I do these steps :

in database :
1- create user user1 identified by user1;
2- grant create session to user1;
3- create role role1;
4 - grant select on ali.CUSTOMERS to role1
5- grant role1 to user1
6- create user user1_proxy identified by user1_proxy
7- alter user user1 grant connect through user1_proxy with role role1


Now in sqlplus I test it
SQL> connect user1_proxy[user1]/user1_proxy
Connected.


my application code is like this :



import java.sql.SQLException;

import oracle.jdbc.OracleConnection;
import oracle.jdbc.OracleResultSet;
import oracle.jdbc.OracleStatement;
import oracle.jdbc.pool.OracleDataSource;

import oracle.jdbc.pool.OracleDataSource;

public class ConectClass {
public static void main(String[] args) throws SQLException{
System.out.println("d1");
OracleDataSource ods = new OracleDataSource();

ods.setURL("jdbc:oracle:thin:user1/user1@192.168.41.141:1521:db1");
OracleConnection conn =(OracleConnection) ods.getConnection();

java.util.Properties prop = new java.util.Properties();
prop.put(OracleConnection.PROXY_USER_NAME, "user1_proxy");
prop.put(OracleConnection.PROXY_USER_PASSWORD,"user1_proxy");
String[] roles = {"role1"};
prop.put(OracleConnection.PROXY_ROLES, roles);
conn.openProxySession(OracleConnection.PROXYTYPE_USER_NAME, prop);

OracleStatement ostmt=(OracleStatement) conn.createStatement();
OracleResultSet rs=(OracleResultSet) ostmt.executeQuery("select user from dual");
while(rs.next()){
System.out.println(rs.getString(1));
}
System.out.println("d2");
}
}


but it return this error :
ORA-28150: proxy not authorized to connect as client


do you know what is wrong here ?

thank you
Re: ORA-28150 when I use proxy user by JDBC , but sqlplus not [message #459491 is a reply to message #459488] Sun, 06 June 2010 02:51 Go to previous message
Michel Cadot
Messages: 68728
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
It is the opposite in your user/proxy_user parameters:
ods.setURL("jdbc:oracle:thin:user1_proxy/user1_proxy@192.168.41.141:1521:db1");
OracleConnection conn =(OracleConnection) ods.getConnection();

java.util.Properties prop = new java.util.Properties();
prop.put(OracleConnection.PROXY_USER_NAME, "user1");
prop.put(OracleConnection.PROXY_USER_PASSWORD,"user1");
String[] roles = {"role1"};
prop.put(OracleConnection.PROXY_ROLES, roles);
conn.openProxySession(OracleConnection.PROXYTYPE_USER_NAME, prop);

Regards
Michel

Previous Topic: How to Automate Daily Monitoring Excel sheet
Next Topic: Metadata is displayed is old through JDBC even if Table is altered
Goto Forum:
  


Current Time: Sat Dec 21 20:49:50 CST 2024