Problems in using Callable Statements..
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Shashank_Arora
Posted On:   Tuesday, September 17, 2002 02:26 AM

Hi :) i have developed an application using servlets and have SQLServer 2000 as my database, and the Web server i am using is Tomcat 4.0.4. The problem i ma having is that i have used some Stored procedures and in one such procedure which is having nvarchar(n) datatype as the parameter and when i am calling this stored proceudure in my Servlet code using the Callable Statement wherein i am passing a String type variable for the Stored Procedure which i feel is compatible with the nvarchar(n) data type of the SQL. But when i am calling the stored procedure with the String tpe variable as parameter the Tomcat shows an error as :: ^error : java.sql.SQLException: [Microsoft][ODBC SQL Server Dri   More>>

Hi :)




i have developed an application using servlets and have SQLServer 2000 as my database, and the Web server i am using is Tomcat 4.0.4.


The problem i ma having is that i have used some Stored procedures and in one such procedure which is having nvarchar(n) datatype as the parameter and when i am calling this stored proceudure in my Servlet code using the Callable Statement wherein i am passing a String type variable for the Stored Procedure which i feel is compatible with the nvarchar(n) data type of the SQL. But when i am calling the stored procedure with the String tpe variable as parameter the Tomcat shows an error as ::




^error : java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification





so it is essentially showing an error converting the String type to nvarchar(n). and i really donn't know any other datatype in Java that is comatible with nvarchar(n). and so how do i execute my stored procedure thru my servlets.?? those who don't know about Java Servlets just can help me out regarding nvarchar datatype and is it compatible with the String type (some strange prob that i m havin is that nvarchar does not but nvarchar(n) raises an error.but nvarchar does not return any results...Strange.....!!)


I am sendin the procedure as well as the servlet code that i m usind to call it..






PROCEDURE STARTS HERE........



CREATE PROCEDURE getMachineDetails @relocationNo varchar(30) AS SELECT * FROM ITEM_ISSUED_DETAILS where s_no=(select s_no from ITEM_ISSUED_DETAILS_HISTORY
WHERE (relocation_no = @relocationNo) AND (date_of_relocation = (SELECT MAX(date_of_relocation) FROM ITEM_ISSUED_DETAILS_HISTORY
WHERE (relocation_no = @relocationNo))))



ENDS HERE...................







SERVLET CODE STARTS HERE......




String machineID="somevalue";



CallableStatement cstmt=con.prepareCall("{call getMachineDetails(?)}");



cstmt.setString(1,machineID);// Error comes here



rs=cstmt.executeQuery();






ENDS HERE...................







If somebody can help me out in this regard, i'll really be so much greatful.



Thanks


Shashank :)

   <<Less

Re: Problems in using Callable Statements..

Posted By:   Raj_Subramani  
Posted On:   Tuesday, September 17, 2002 04:41 AM


Have never worked with SQL Server so a total shot in the dark.

Why not convert the String to a char array before passing to the query (String.toCharArray()).


Cheers

-raj

About | Sitemap | Contact