I've been reviewing some of the threads here and applying some of the advice and still getting the same error. - 15:50:26,935 INFO [STDOUT] java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Could not find stored procedure 'getName'.
I'm basically taking a variable coming to my servlet through a JSP page and using it as my search criteria. I know the stored proc will execute through query analyzer, I can execute a regular prepared statement through my servlet, so i know I'm connecting okay, but I'm still baffled. I have included my servlet and SQL Server procedure:
Servlet: - import java.io.IOException;
-
import java.sql.CallableStatement;
-
import java.sql.Connection;
-
import java.sql.DriverManager;
-
import java.sql.ResultSet;
-
import java.sql.SQLException;
-
import javax.servlet.ServletException;
-
import javax.servlet.http.HttpServlet;
-
import javax.servlet.http.HttpServletRequest;
-
import javax.servlet.http.HttpServletResponse;
-
-
public class VoidMemberServlet extends HttpServlet {
-
-
private static final long serialVersionUID = 1L;
-
-
Connection conn = null;
-
public VoidMemberServlet() {
-
super();
-
-
}
-
-
public void destroy() {
-
super.destroy();
-
}
-
-
public void doGet(HttpServletRequest request, HttpServletResponse response)
-
throws ServletException, IOException {
-
-
String state = (String)request.getSession().getAttribute("state");
-
if(state != "" &&state!=null)
-
callProcedure(state);
-
}
-
-
-
public void doPost(HttpServletRequest request, HttpServletResponse response)
-
throws ServletException, IOException {
-
-
}
-
private void callProcedure(String state)
-
{
-
try {
-
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
-
conn = DriverManager.getConnection(
-
"jdbc:microsoft:sqlserver://SERVER1:1433;database=test;user=sa;password=password");
-
-
-
//PreparedStatement statement = conn.prepareStatement("select * from SERVER1.test.dbo.allUsersinSystem");
-
//ResultSet set = statement.executeQuery();
-
-
CallableStatement cstmt = conn.prepareCall("{Call getName(?)}");
-
cstmt.setString(1,state);
-
-
cstmt.execute();
-
ResultSet set = cstmt.getResultSet();
-
-
cstmt.close();
-
conn.close();
-
-
while(set.next())
-
{
-
System.out.println(set.getString("uname"));
-
}
-
-
} catch (ClassNotFoundException e) {
-
-
e.printStackTrace();
-
} catch (SQLException e) {
-
// TODO Auto-generated catch block
-
e.printStackTrace();
-
} catch (InstantiationException e) {
-
// TODO Auto-generated catch block
-
e.printStackTrace();
-
} catch (IllegalAccessException e) {
-
// TODO Auto-generated catch block
-
e.printStackTrace();
-
}
-
-
}
-
-
public void init() throws ServletException {
-
-
}
-
-
}
There are appropriate execute permissions on all the users and the sproc looks something like: -
CREATE PROCEDURE getName (@State varchar(2))
-
as
-
Select uname
-
FROM allUsersinSystem
-
WHERE state=@State
-
GO
I dont know how I can execute a prepared statement on a table in the same database, but I can't execute the sproc.
Any suggestions would be great,
Thanks,
-Dave
3 2233
welcome jynxxxed,
actually i m from oracle ... there is a synonym and grand funda.
i m not sure is there any funda in MicroSoft sqlserver.
so u better to forward this post to the database forums.
and i thing i saw in ur code ... that u r accessing the resultset object after closing statement and connection objects.
u must use the resultset object before closing the statement object.
best of luck jynxxxed.
Well,
That's true, I am accessing the result set object after closing the connection and Callable statement, but I thought that since I set the ResultSet while they're still open, I could access it without worrying about the connection.
But I am still unsure why I can't execute the callable statement though, and why I would get the error, "Cannot Find Stored Procedure 'getName' ".. I'm definitely baffled.
Sorry for posting in the wrong section, I will move this thread over to the Database section.
Thanks,
-Dave
the resultset object is associated with statement object and the statement object is associated with connection object.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Google Mike |
last post by:
After a lot of thought and research, and playing with FreeTDS and
InlineTDS, as well as various ODBC connections, I have determined that
the fastest and cheapest way to get up and going with PHP on Linux,
connecting to MS SQL Server, unless it was already pre-installed by
your Linux installation, is to build your own multithreaded TCP socket
server on Windows and connect to it through the socket API in PHP on
Linux (if you have installed...
|
by: Jeager |
last post by:
Why is it, Microsoft manage to write operating systems and office
applications with every bell and whistle facility known to man. Yet,
even after years and years of development they still cannot produce a
decent version of MS SQL Server, one without a plethora of flaws and
limitations? Personally I'd sack the MS SQL Server Chief Architect,
start addressing some fundementals and do what MS do best - copy the
best functionality of their...
|
by: rickcheney |
last post by:
I just changed my Access 2002 database to a SQL Server ADP project. I
had a form where the user entered a value into a text box and when a
command button on the form was clicked a Report was opened. The reports
record source is a query. The query uses the value from the form text
box to restrict the query.
Table name = EggsTable
one of the columns in the table is named: EggColor
Form name = EggColorForm
Form text box name = ColorTextBox
|
by: dmalhotr2001 |
last post by:
Hi,
I have an issue with my query.
1. I have 1 stored proc which have execution calls to multiple stored
procs within it.
2. I want to wrap that main stored proc in the transaction and rollback
if there are errors execution calls to other stored procs. I don't
believe my code is accounting for errors occuring in the execution
|
by: Dave Sisk |
last post by:
I've created a system or external trigger on an AS/400 file a.k.a DB2 table.
(Note this is an external trigger defined with the ADDPFTRG CL command, not
a SQL trigger defined with the CREATE TRIGGER statement.) I've also defined
a SQL stored proc, and the trigger is set to call this SP. I've posted the
simplified source below. I can manually call the stored proc, and the
external trigger is created without any errors. However, when I do...
| |
by: Rhino |
last post by:
I am getting an sqlcode of -927 when I execute SQL within a COBOL stored
procedure in DB2 OS/390 Version 6 on OS/390. I have looked at the error
message for that condition and tried everything I could think of to resolve
the problem but nothing works.
The stored proc is running in the DB2 Stored Procedures Address Space and
both the client and the proc have DSNELI linked into their load modules. The
client and proc are running in TSO via...
|
by: xAvailx |
last post by:
Hello:
I didn't find any documentation that notes save point names are case
sensitive, but I guess they are...
Stored Proc to reproduce:
/* START CODE SNIPPET */
If Exists (Select * From sysobjects Where Type = 'P' and Name =
|
by: hicks |
last post by:
I'm trying to invoke a DB2 stored procedure. The stored proc is coded
in C and compiled to a shared library, which has been placed in the
<DB2 dir>/functions directory. The platform is Solaris.
>From the debug log it seems that the stored procedure can't be found,
although I don't know why. Using the control centre, I can see that the
procedure name is defined in the database, however it can not be
invoked.
Can anyone shed any light on...
|
by: balaji krishna |
last post by:
Hi, I need to handle the return set from COBOL stored procedure from my invoking Java program. I do not know, how many rows the stored proc SQL fetches.I have declared the cursor in that proc, but i don't know how to return the rows the cursor has opened and I don't know how to handle the return set from the proc in my java code.
My main problem with that proc is that whether I can retun the result set from the proc without closing the cursor...
|
by: rbg |
last post by:
I did use query plans to find out more. ( Please see the thread BELOW)
I have a question on this, if someone can help me with that it will be
great.
In my SQL query that selects data from table, I have a where clause
which states :
where PermitID like @WorkType
order by WorkStart DESC
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |