aspose file tools*
The moose likes JDBC and the fly likes MSSQL CallableStatement Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MSSQL CallableStatement Issue" Watch "MSSQL CallableStatement Issue" New topic
Author

MSSQL CallableStatement Issue

jeramia vontez
Greenhorn

Joined: Jan 10, 2006
Posts: 3
Hello all so I have literly beat my head against a wall on this issue and been up all night.

rundown: I am using a callablestatement to access a mssql db stored procedure through jdbc, (if you would like the driver info i can post l8tr). My code is simple but I keep getting the following error and I have tried everything and searched everywhere it seems to fix this so I behold myself to you the wiser.

MSSQL Stored Procedure:

CREATE PROCEDURE www_Check_Disp_Contrato_Tipo_Fechas @cont int,
@thab int,
@f_ent datetime,
@f_sal datetime,
@respetar_release bit,
@lDisp bit output
AS

/* Procedimiento que chequea si hay disponibilidad contra cupos para todos los dias del periodo de fechas pasado como parametro de un
contrato para un tipo de habit dado y respetando el release del contrato, solo devuelve 1 si hay disponibilidad para todos los dias
*/

begin
declare @dia_inic datetime, @release int, @disp int,@cupos int,
@dia_sal datetime,@fecha_hotelera datetime,@ocup int,
@reserv int,@hab_salen int, @ncupos int, @room int

Select @dia_sal = @f_sal
Select @dia_inic = @f_ent
Select @lDisp = 1

Select @fecha_hotelera = fecha_hotelera From Hotetabl
While DATEDIFF(day,@dia_inic,@dia_sal) >= 0 and @lDisp = 1
begin
Execute Calc_Hab_Sal_Dia_Cont_Tipo @cont, @thab, @dia_inic, @hab_salen output
Execute Calc_Cupos_Cont_Dia_Tipo @cont, @dia_inic, @thab, @cupos output
Execute Calc_Hab_Ocup_Cont_Dia_Tipo @cont, @dia_inic, @thab, @ocup output
Execute Calc_Hab_Res_Cont_Dia_Tipo @cont, @dia_inic, @thab, @reserv output
Execute Calc_Hab_Room_Cont_Dia_Tipo @cont, @dia_inic, @thab, @room output
Execute Calc_Release_Contrato @cont, @dia_inic, @release output

if @respetar_release = 1
if DATEDIFF(day,@fecha_hotelera,@dia_inic) < @release
Select @ncupos = 0
else
Select @ncupos = @cupos
else
Select @ncupos = @cupos

Select @disp = @ncupos - @ocup - @reserv - @room + @hab_salen

if @disp <= 0
Select @lDisp = 0

Select @dia_inic = DATEADD(day,1, @dia_inic)
end


end




***************************************
The Code I'm using:

CallableStatement cs = conn.prepareCall("{call www_Check_Disp_Contrato_Tipo_Fechas(?,?,?,?,?,?)}");


int cont = 632;
int thab = 112;
java.sql.Date entrada = new java.sql.Date(2006,01,15);
java.sql.Date salida = new java.sql.Date(2006,01,18);

cs.setInt(1, cont);
cs.setInt(2, thab);
cs.setDate(3, entrada);
cs.setDate(4, salida);
cs.setBoolean(5, true);
cs.registerOutParameter(6, Types.NUMERIC);

cs.execute();

int outParam2 = cs.getInt(6);

****************************************************
I receive the following error msg:
[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Formal parameter '@respetar_release' was defined as OUTPUT but the actual parameter not declared OUTPUT

****************************************************

To me it makes no sense becuase I am not defining the 5th input "respetar_release" as the OUTPUT???
Any suggestions or links will be greatly appreciated as this seemingly small issue could derail my whole project!!

Thanks in advance, peace and respect to all of you!
 
jQuery in Action, 2nd edition
 
subject: MSSQL CallableStatement Issue