Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting values by calling stored proc. in sql server

 
harjit bedi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Friends,
I just wanted to know that how would u get the value of a variable (which is an output parameter in sql server) by calling it in java.
example
create procedure proc1
(@a varchar(10),
@id varchjar(3)
as
begin
select @id=@a+' returned value'
end
above is a procedure made in MS sql server.
now what i want is by calling this procedure in java sending two variables and getting the value of second variable
if possible make a program
thank u
 
T Bush
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something like this....
Connection con .... make connection
Statement stmt = con.createStatement();
ResultSet rst = stmt.executeQuery("exec proc1 'arg1', 'arg2'");
rst.next();
String result = rst.getString(0);
This would be the basic framework. You could use PreparedStatement for more dynamic content with your query...
Sorry in advance if my syntax is wrong....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic