I have a jsp that will add users for an application to the database. If the user tries to add a new user that is already in the database, the stored procedure (Sybase) is printing out text saying that 'This user already exists with the following information.' and then prints the resultset of a select query on the table for the given username. How do I handle that from Java? I know of CallableStatement.registerOutParameter(), but can this method handle this return? If I register the out parameter as a String (is this possible), could I save all of this text into a String so I can display it to the user? Please help me handle this appropriately. I really want to display this String from the database, as I feel it is a more meaningful message than just telling the user 'This person is already registered as a user.' Thanks for any and all help you are able to provide!
You can return multiple parameters from the stored procedure, set them as OUT parameters. eg. CallableStatemnt cst.... cst.registerOutParameter(1, java.sql.Types.VARCHAR);//userid cst.registerOutParameter(2, java.sql.Types.VARCHAR);//username cst.setString(3, "new username"); cst.execute(); userid = cst.getString(1); username = cst.getString(2);
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop