Thread: passing a String[] to a Stored function

passing a String[] to a Stored function

From
"Nagesh Yencharla"
Date:
<div style="background-color:"><div><p><table bgcolor="#666699" border="0" cellpadding="4" cellspacing="1"
width="100%"><tbody><trbgcolor="#ddddff"><td><font size="4"></font></td></tr><tr bgcolor="#ffffff"><td><font
size="4">HiAll,<br /><br />I would like to know how i can pass String[] to function. To give a clearer idea i have to
codebelow. <br />I am using PostgreSQL 7.3.<br /><br />Any help regarding this is appreciated.<br /><br /><br />Thanks
inadvance,<br />Nagesh <br /><br /><br />class testArray {<br />public static void main(String args[]) {<br
/>test();<br/>}<br /><br /><code><br />static void test()<br />{<br /><br />String url =
"jdbc:postgresql://myDB:5432/dbinstance";<br/>String query="{call test_mohan(?)}";<br />Connection con = null;<br
/>CallableStatementstmt=null;<br />try {<br />Class.forName("org.postgresql.Driver");<br
/>con=DriverManager.getConnection(url,"blah","blah"); <br />String string[]=new String[]{"hi","hello"};<br />//not sure
howto use string array above and pass to setArray below or use another solution<br /><br />stmt.setArray(1, );<br
/>stmt= con.prepareCall(query);<br />ResultSet rs=stmt.executeQuery();<br />while(rs.next())<br />{<br />.....<br
/>}<br/><br />} catch(Exception ex) {<br />System.out.println ("Get Data Fail: " + ex);<br />}<br />finally{<br
/>........<br/>}<br />}<br />}</font></td></tr></tbody></table><br /><br /></div></div><br clear="all" /><hr />MSN 8
with<a href="http://g.msn.com/8HMEENUS/2740">e-mail virus protection service: </a> 2 months FREE*