wood burning stoves*
The moose likes JDBC and the fly likes getting values by calling stored proc. in sql server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "getting values by calling stored proc. in sql server" Watch "getting values by calling stored proc. in sql server" New topic
Author

getting values by calling stored proc. in sql server

harjit bedi
Greenhorn

Joined: Dec 09, 2000
Posts: 3
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

Joined: Jul 31, 2000
Posts: 13
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....


Todd Bush<BR>AIM: RalphWiggam14
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting values by calling stored proc. in sql server
 
Similar Threads
Problem retrieving output from stored procedured
Problem calling IN parameters Stored Procedure from Java
VARBINARY in sp -how-to
Getting value from stored procedure ??
CallableStatement problem