• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to call a stored procedure from java

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I am using sybase database and trying to call a SP.
The following code i am using.
import java.sql.*;
public class javaTest
{
public static void main(String [] str1)
{
try
{
String svr = "tkd-imsyb-01.tk.jp.chase.com:4100";
String uid ="JBOND";
String pwd ="waltherppk";
String department = "MTB";
Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
Connection con = DriverManager.getConnection("jdbc:sybase:Tds:"+svr,uid, pwd);
Statement stm = con.createStatement();
ResultSet rst = stm.executeQuery("exec get_user_func 'YKIDACHI','cftrade' ");
while(rst.next())
{
System.out.println("-----:"+rst.getString(0));
}

}catch(Exception e)
{
e.printStackTrace();
}
}
}

When i run this program its giving the following exception.
java.sql.SQLException: JZ0R2: No result set for this query.
at com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:482)
at com.sybase.jdbc2.jdbc.SybStatement.queryLoop(SybStatement.java:1525)
at com.sybase.jdbc2.jdbc.SybStatement.executeQuery(SybStatement.java:149
5)
at com.sybase.jdbc2.jdbc.SybStatement.executeQuery(SybStatement.java:402
)
at javaTest.main(javaTest.java:22)

If i execute the SP from isql it gives me a result.
Can some body help me.
Radha
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use java.sql.CallableStatement for executing stored procedures.
 
Radha MahaLakshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
I need to soecidy the db name before SP name as matrix_xref..get_user_func insted get_user_func then its working.
Thanks
Radha
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic