-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Call stored procedure via jdbc
PostPosted: Tue May 23, 2006 10:43 am 
Regular
Regular

Joined: Mon May 22, 2006 8:32 am
Posts: 67
Hi all,

i try to execute a stored procedure via jdbc on sybase.


Code:
...
Session session = null;
java.sql.ResultSet result = null;
java.sql.PreparedStatement st;      

SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session = sessionFactory.openSession();
         

try {
st = session.connection().prepareCall("{call ta_generic_password_check (?,?)}");
   session.connection().setAutoCommit(true);
   st.setString(1, userName);
   st.setString(2, hash);

   result = st.executeQuery();

   while (result.next()){
      System.out.println(result.getString(1));
   }

} catch (HibernateException e) {
   e.printStackTrace();
} catch (SQLException e) {
       e.printStackTrace();
}


My problem: result.next is never true. I tried the statement in asp code. There it worked fine. What am I doing wrong?

Regards,

Barnti


Top
 Profile  
 
 Post subject: Sybase stored procedure via jdbc
PostPosted: Wed May 24, 2006 3:52 am 
Regular
Regular

Joined: Mon May 22, 2006 8:32 am
Posts: 67
Hi all,

i found the anwser: Wrong login parameters! Here is the code for executing a stored procedure in sybase via jdbc:

...
Session session = null;

SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();

session = sessionFactory.openSession();

CallableStatement sproc_stmt;
try {
sproc_stmt = session.connection().prepareCall("{call ESDB.dbo.ta_generic_password_check (?,?)}");
sproc_stmt.setString(1, userName);
sproc_stmt.setString(2, hash);
sproc_stmt.setFetchSize(10);

SybCursorResultSet sproc_result = (SybCursorResultSet) sproc_stmt.executeQuery();

while(sproc_result.next()){
System.out.println(sproc_result.getString(1));
System.out.println(sproc_result.getString(2));
System.out.println(sproc_result.getString(3));
System.out.println(sproc_result.getString(4));
}
} catch (HibernateException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}



[code][/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.