You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by an...@jpmchase.com on 2005/08/09 12:50:40 UTC
SQLMaps - Sybase and stored procedures
Hi,
I have a question regarding the use of stored procedures (in particular
Sybase) with SQLMaps.
Having looked at the documentation I am still unsure as the documentation,
unless I have missed it, doesnt deal with getting results back from
the proc.
I wish to call a Sybase stored procedure, passing into two parameters and
retrieving a String value in a resultset.
The proc, which provides a language translation, takes two String
parameters (the text you wish translated, and the language
you wish translated to) and then returns a String value of the translated
text.
My sqlmap is as follows:
<parameterMap id="languageLookupMap" class="java.util.HashMap">
<parameter javaType="java.lang.String" mode="IN" jdbcType="VARCHAR"
property="from_text"/>
<parameter javaType="java.lang.String" mode="IN" jdbcType="VARCHAR"
property="language"/>
</parameterMap>
<procedure id="languageLookup" parameterMap="languageLookupMap">
{call language_lookup @from_text = ?, @language = ?}
</procedure>
My code is as follows:
HashMap map = new HashMap();
map.put("from_text", "Computers");
map.put("language", "FRE");
ArrayList results = (ArrayList) sqlMap.queryForList("testLanguageLookup",
map);
iter = results.iterator();
System.out.println("results = " + results.toString());
When I run the code, the output is always "result = []".
However, if I run the following regular jdbc code, I get a valid result:
CallableStatement cstmt = conn.prepareCall("{call language_lookup
@from_text = 'Computers', @language = 'FRE'}");
ResultSet rs = cstmt.executeQuery();
System.out.println("Resultset = " + rs.toString());
rs.next();
String output = (String) rs.getString(1);
System.out.println("Output = " + output);
The output is ----->
Resultset = com.sybase.jdbc2.jdbc.SybResultSet@5fc75b3
Output = Ordinateurs
Can anyone give me some tips to get the same eresults with SQLMaps as I get
with regular jdbc code?
Thanks in advance,
andy