I'm trying to use a servlet to process a form, then send that data to
an SQL server stored procedure. I'm using the WebLogic 8 App. server.
I am able to retrieve database information, so I know my application
server can talk to the database.
I've determined the failure occurs when the the following statement is
executed: cstmt.execute() ; (due to the failure of println statements
placed afterwards). I get the following error after trying to execute
the stored procedure call:
[Microsoft][ODBC SQL Server Driver][SQL Server]Could not find stored
procedure 'insertTheForm'
The username and password i'm using to connect is a Windows user with
admin rights. It is also associated with the Odbc connection--and of
course is a database user..with full rights. I have executable
permissions on the stored procedure set up as well. I did a microsoft
recommended registry fix as well (for a previous
error:http://support.microsoft.com/default...en-us;Q238971).
Am I missing something? I posted my servlet code below.
Thanks for any help!
Dinesh
formHandlingSer vlet.class
-------------------------
package showme;
/*
* formHandlingSer vlet.java
*
* Created on July 6, 2003, 7:01 PM
*/
import javax.servlet.* ;
import javax.servlet.h ttp.*;
import java.io.*;
import java.sql.*;
import java.text.DateF ormat;
/**
*
* @author Administrator
*/
public class formHandlingSer vlet extends HttpServlet {
private static final String email1 = "email";
private static final String password1 = "password1" ;
private static final String password2 = "password2" ;
private static final String displayname = "displaynam e";
Connection dbConn = null;
// create a persistent conneciton to the SQL server
public void init() throws ServletExceptio n
{
String jdbcDriver = "sun.jdbc.odbc. JdbcOdbcDriver" ;
String dbURL = "jdbc:odbc:Con2 ";
String usernameDbConn = "dinesh";
String passwordDbConn = "werty6969" ;
try
{
Class.forName(j dbcDriver).newI nstance();
dbConn = DriverManager.g etConnection(db URL, usernameDbConn,
passwordDbConn) ;
}
catch (ClassNotFoundE xception e)
{
throw new UnavailableExce ption("jdbc driver not found:" + dbURL);
}
catch (SQLException e)
{
throw new UnavailableExce ption("error: " + e);
}
catch (Exception e)
{
throw new UnavailableExce ption("error: " +e);
}
}
public void doPost(HttpServ letRequest request, HttpServletResp onse
response) throws ServletExceptio n, IOException
{
response.setCon tentType("text/plain");
PrintWriter out = response.getWri ter();
//extract parameter information from register.jsp
String email1 = request.getPara meter("email1") ;
String password1 = request.getPara meter("password 1");
String password2 = request.getPara meter("password 2");
String displayname = request.getPara meter("displayn ame");
try
{
//make a callable statement for a stored procedure.
//It has four parameters
CallableStateme nt cstmt = dbConn.prepareC all(
"{call insertTheForm(? , ?, ?, ?)}");
//set the values of the stored procedure's input parameters
out.println("ca lling stored procedure . . .");
cstmt.setString (1, email1);
cstmt.setString (2, password1);
cstmt.setString (3, password2);
cstmt.setString (4, displayname);
//now that the input parameters are set, we can proceed to execute the
insertTheForm stored procedure
cstmt.execute() ;
out.println("st ored procedure executed");
}
catch (SQLException e)
{
throw new UnavailableExce ption("error: " + e);
}
}
}