Calling a stored procedure with a parameter

Calling a stored procedure with a parameter

Post by Brandon Olso » Fri, 21 Dec 2001 08:02:42



Hello,

I am trying to call a SQL Server stored procedure that needs a parameter.
My sample code looks like this so far:

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn =
DriverManager.getConnection("jdbc:microsoft:sqlserver://clarksql-1:1433;Data
baseName=lcr","sa","");
CallableStatement cstmt = conn.prepareCall("{call MLSListings_GetByID}");
ResultSet rs = cstmt.executeQuery();

How and Where do I insert the value for the stored procedures parameter?

Thanks for the help!!

Brandon Olson

 
 
 

Calling a stored procedure with a parameter

Post by Volker Berli » Fri, 21 Dec 2001 23:06:21


CallableStatement cstmt = conn.prepareCall("{call MLSListings_GetByID(?)}");
cstmt.setObject(1, YourParameter);
ResultSet rs = cstmt.executeQuery();

Volker Berlin
i-net software

Brandon Olson schrieb in Nachricht ...

Quote:>Hello,

>I am trying to call a SQL Server stored procedure that needs a parameter.
>My sample code looks like this so far:

>Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
>Connection conn =
>DriverManager.getConnection("jdbc:microsoft:sqlserver://clarksql-1:1433;Dat
a
>baseName=lcr","sa","");
>CallableStatement cstmt = conn.prepareCall("{call MLSListings_GetByID}");
>ResultSet rs = cstmt.executeQuery();

>How and Where do I insert the value for the stored procedures parameter?

>Thanks for the help!!

>Brandon Olson


 
 
 

1. Call a Stored Procedure with default parameter by OLE DB

calling a stored procedure by OLE DB has two ways
1. using ODBC CALL Escape Sequence, for example
{call InsertOrder(, 10, ?)}
The first parameter of the Stored Procedure has a default
value. I just need to bind the third parameter.

2. using RPC Escape Sequence, for example
{rpc InsertOrder}

I can set parameter infomation for the second and third
parameter, however how to set default value for the first
parameter?

2. Backup

3. Calling a stored procedure with parameters from another stored procedure

4. Lotus SmartSuite 96 Approach Question

5. 16722-DE-Wilmington-Visual Basic-Visual C++-SQL-Document Management-Developer

6. Error at obtaining output parameters of the stored procedure, calling other stored procedure

7. About ListBox in Grid( How to copy list)

8. Calling Stored Procedure that calls Stored Procedure in ASP

9. Can you call Oracle Stored Procedure with named parameters?

10. Calling a Java Stored Procedure from another Java Stored Stored Procedure

11. How to call/execute a stored procedure with parameters from code

12. Calling a Stored Procedure with parameters