sql - Why won't this stored procedure call from Java work? -


here stored procedure:

create or replace procedure viewbrokers  (o_username out users.username%type)    begin  select username  o_username  users role_id = 3 ;  end viewbrokers; 

here method calling stored procedure:

public resultset pullbrokers() {     resultset rs = null;     try {         drivermanager.registerdriver(new oracle.jdbc.driver.oracledriver());         con = drivermanager.getconnection(messages.getstring("oracleusermanagement.0"), messages.getstring("oracleusermanagement.1"), messages.getstring("oracleusermanagement.2")); //$non-nls-1$ //$non-nls-2$ //$non-nls-3$          string storedprocedure = "{call viewbrokers(?)}";      callablestatement statement = con.preparecall(storedprocedure);      statement.registeroutparameter(1, java.sql.types.varchar);     rs = statement.executequery();      con.commit();     con.close();  } catch (sqlexception e) {     e.printstacktrace(); } return rs; } 

and lastly when tried print out results:

public class test {     public static void main(string[] args) throws sqlexception{         oraclepulllistofusers pull = new oraclepulllistofusers();          resultset rs = pull.pullbrokers();         try {             while (rs.next()){                 system.out.println(rs.getstring(1));         }             } catch (sqlexception e) {                 e.printstacktrace();             }     } } 

i error message ora-01422: exact fetch returns more requested number of rows

which strange ,because there 2 rows of data in table...

if point me in right direction, awesome!

looks you're problem not related java, on sql side. both 2 rows in table have role_id=3?


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -