Re: Passing DB Name/Owner Name in a prepareCall statement

rkennel_at_veng.com
Date: 08/26/04


Date: 26 Aug 2004 11:46:29 -0700

Thanks Joe,

I found the culprit in an extended class. It was prepending a default
databaseName.ownerName. causing this "weird" behavior. A wasted
thread,

{CALL dbname.ownername.sp_name (?,?,?)}

will work.

Joe Weinstein wrote:
> Ryan wrote:
>
> > Joe Weinstein <joeNOSPAM@bea.com> wrote in message
news:<412CF482.9070904@bea.com>...
> >
> >>Ryan wrote:
> >>
> >>
> >>>When calling a stored procedure in sql server passing just the
Stored
> >>>Procedure name, my stored procedure name works correctly. Below
is
> >>>the String I use when performing Connection.prepareCall(String)
> >>>
> >>> {CALL sp_name (?,?,?)}
> >>>
> >>>However when I want to specify the db name and the user name (name
of
> >>>the user who owns the sp), I get an error that the driver could
not
> >>>find the stored procedure.
> >>
> >>It's the DBMS, not the driver, that can or cannot find a stored
procedure.
> >>Your JDBC SQL seems fine. Show the actual exception you get. Maybe
that will
> >>help.
> >>
> >> Any clues as to how this could be fixed?
> >>
> >>>In other words, how can I set the default database name and owner
name
> >>>to query against?
> >>>
> >>> {CALL dbName.username.sp_name (?,?,?)}
> >
> >
> > I get the following exception:
> >
> > java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
> > JDBC][SQLServer]The procedure name
> > 'dbName.username1.dbName.userName2.' contains more than the maximum
> > number of prefixes. The maximum is 3.
> >
> > The call I pass to Connection.prepareCall is:
> > {CALL dbName.username2.sp_name (?,?,?)}
> >
> > where dbname = the name of the database that I logged into.
Username1
> > is the username that I logged in with. Username2 is the username
of
> > the owner of the stored procedure and sp_name is the name of the
> > stored procedure.
>
> very odd. Does this code work for you?
> It does for me... (logging in as a non-sa user...)
>
> Statement s = c.createStatement();
> s.execute("use tempdb");
> s.execute("exec master.dbo.sp_who");
>
> PreparedStatement p = c.prepareStatement("{ call
master.dbo.sp_who() }");
> p.execute();
>
> CallableStatement cl = c.prepareCall("{ call master.dbo.sp_who()
}");
> cl.execute();



Relevant Pages

  • Re: generating sql scripts of stored procedures
    ... What could be causing this ... > Whenever I build a new stored procedure into my database I specifically ... > at the end of the script. ... All my settings in sql server and database ...
    (microsoft.public.sqlserver.programming)
  • Re: Connecting Trace info to blocked users?
    ... > Loginame is causing the block. ... > command that the offending blocker is running to cause the block, ... > it only says "SELECT" etc. with no details about the stored procedure ... > including the parameters that every cmd is running. ...
    (comp.databases.ms-sqlserver)
  • Help with error
    ... Does anyone know what is causing this? ... stored procedure in an iseries. ... Dim cmd As New iDB2Command(sql, ... Joe in Florida ...
    (microsoft.public.dotnet.languages.vb)
  • Connecting Trace info to blocked users?
    ... Loginame is causing the block. ... command that the offending blocker is running to cause the block, ... it only says "SELECT" etc. with no details about the stored procedure ... including the parameters that every cmd is running. ...
    (comp.databases.ms-sqlserver)
  • Re: Automated mail merge from a stored procedure
    ... I found what was causing my problem & thought I'd post in case anyone ... experiences the same problem. ... My stored procedure had a "Print" statement in it that I'd been using ... Peter Carpenter. ...
    (microsoft.public.word.mailmerge.fields)

Loading