1

This one has baffled me for a long time, so I am trying to get some help here :)

I am using JDBC to connect to an age old Sybase Adaptive server 6 (!!!) I couldn't even find the JDBC drivers for it online, so I copied them from the installation directory :)

Now, inserting and querying and all the rest of the db operations work fine, but I encounter problems when calling a stored procedure. Let's start first with a snippet of code:

CallableStatement loginProcedure = connection.prepareCall("{call Login}");
loginProcedure.executeUpdate();

This is some normal procedure calling code. I must add that the Login procedure does not take any paramaters nor it outputs something back. The only thing that it does is to create a varibale in the db named AiCol. I will update this post soon with the procedure code as well.

When executing the above code I get the standard syntax exception:

com.sybase.jdbc.SybSQLException: ASA Error -131: Syntax error near 'Login'
    at com.sybase.tds.Tds.processEed(Tds.java)
    at com.sybase.tds.Tds.nextResult(Tds.java)
    at com.sybase.jdbc.ResultGetter.nextResult(ResultGetter.java)
    at com.sybase.jdbc.SybStatement.nextResult(SybStatement.java)
    at com.sybase.jdbc.SybStatement.executeLoop(SybStatement.java)
    at com.sybase.jdbc.SybCallableStatement.execute(SybCallableStatement.java)

Anyone encountered this problem before? It is my first time calling a stored procedure with no IN/OUT parameters, so I might be doing something wrong :/

Thanks in advance! /ivo

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
trumpets
  • 11
  • 1
  • 2

1 Answers1

0

Just a guess from the jConnect Documentation, but you may need to use a SybCallableStatement.

The demo uses parameters, but I would try calling it with executeUpdate.

I know back in the day, the Sybase standard JDBC support was lacking and they did things their own way for a while. You might want to see if you can track down an old jConnect Manual.

I also thought there was another Java Library at the time before jConnect. It's been a long time since ASE 6!

import com.sybase.jdbcx.*;

....

// prepare the call for the stored procedure to execute as an RPC

String execRPC = "{call " + procName + " (?, ?)}";
SybCallableStatement scs = (SybCallableStatement) con.prepareCall(execRPC);

// set the values and name the parameters

// also (optional) register for any output parameters
scs.setString(1, "xyz");
scs.setParameterName(1, "@p3");
scs.setInt(2, 123);
scs.setParameterName(2, "@p1");

// execute the RPC
// may also process the results using getResultSet()
// and getMoreResults()

// see the samples for more information on processing results
ResultSet rs = scs.executeQuery();
Rakesh
  • 4,004
  • 2
  • 19
  • 31
Mike
  • 3,186
  • 3
  • 26
  • 32
  • Thanks Mike. I will see what I can do in tracking the old documentation. I tried the `SybCallableStatement` and it did not work, and I also tried a `PreparedStatement` with the same results :( – trumpets Aug 13 '12 at 14:40
  • The only other thing I would try is to call it like {call Login()}, which would be a little strange, but it seems like it doesn't like the syntax for some reason. Maybe try {exec Login} or some variant of it. I remember using dblib because Java support wasn't there yet. – Mike Aug 13 '12 at 15:35