Hi,
In my b4j server application I am trying to connect SQL server and execute an stored procedure that returns a NVARCHAR(MAX) in output param.
But I only recieve the first 2000 bytes (utf) of the result string.
Here is the code:
Dim myResponse As String
Dim SQLconnection As SQL = SQLdb.myConnectionPool.GetConnection
Dim CallableStatement As JavaObject = SQLconnection.CreateCallStatement("exec [SP_myStoredProc] ?,?,?,? ", Array("Value_1", "Value_2", "Value_3", "" ))
CallableStatement.RunMethod("registerOutParameter", Array (4,-1))
CallableStatement.RunMethod("execute", Null)
myResponse = CallableStatement.RunMethod("getString",Array (4))
According to this page https://developer.android.com/reference/java/sql/Types
I should use type -16 LongNvarChar which is not supported by jSQL library. So I use data type -1 ( LongVarChar)
How can I have the unlimited length of NvarChar(Max) which is returned by SQL serever?
Accually, the data type -16 is not my problem.
I need to have the full length of the output-param which my sotredProcedure returns (it may be 12,000 bytes or more)
This line of code returns only the first 4000 bytes of it:
Unfortunately, I could not make use of it because when I tried to call functions like getClob or getObject according to the following page, I noticed that getClob method is not supported by the CallableStatement object and getObject returned something that I could not convert to string https://developer.android.com/reference/java/sql/CallableStatement
I guess I am very close to answer but I got disappointed and need your help
Thank you
That code returned only 4000 bytes and encoding was not UTF-8 and some text were converted to '?????'
I think getAsciiStream method is using "US-ASCII" encoding
when I replaced the method name with getCharacterStream, I got this error:
B4X:
java.lang.RuntimeException: java.lang.ClassCastException: java.io.BufferedReader cannot be cast to java.io.InputStream