Exception comes from where?
- From: "PJ Pugh" <msee92_spamfree@xxxxxxxxxxx>
- Date: Thu, 8 Sep 2005 09:10:05 -0700
Being new to SQLServer, I may be doing something very basic wrong, but here's
my problem:
Java servlet code is calling a MSSQL stored procedure, returning this error
message:
Main catch exception java.sql.SQLException: [Microsoft][SQLServer 2000
Driver for JDBC][SQLServer]Line 1: Incorrect syntax near 'insert_person'
Java code as follows:
public String dbInsertPerson(Connection conn) throws Exception {
String curErrorId = "";
CallableStatement procCall = null;
String procString = "";
// Make sure no errors have occurred.
if (curErrorId.equals("")) {
try {
procString = "{call insert_person(?,?,?,?,?,?,?,?,? )}";
procCall = conn.prepareCall(procString);
procCall.setString(1, this.lastName);
procCall.setString(2, this.firstName);
procCall.setString(3, this.middleName);
procCall.setString(4, this.preferredName);
procCall.setString(5, this.dateOfBirth);
procCall.setString(6, this.gender);
procCall.setString(7, this.emailAddress);
procCall.setString(8, this.highSchoolName);
procCall.setString(9, this.highSchoolGradYear);
procCall.executeUpdate();
}
catch (SQLException e) {
curErrorId = "100";
throw e;
}
catch (Exception e) {
curErrorId = "101";
throw e;
}
finally {
if (procCall != null) procCall.close();
}
} // end if
return curErrorId;
}
Stored procedure code as follows:
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure insert_person
@lastName varchar(16),
@firstName varchar(16),
@middleName varchar(16),
@preferredName varchar(16),
@dateOfBirth varchar(30),
@gender varchar(1),
@emailAddress varchar(25),
@highSchoolName varchar(20),
@highSchoolGradYear varchar(4)
AS
insert into people (LastName, FirstName, CreationDate, LastUpdateDate,
MiddleName, PreferredName, DateOfBirth, Gender,
EmailAddress, HighSchoolName, HighSchoolGradYear)
values (@lastName, @firstName, getdate(), getDate(), @middleName,
@preferredName, convert(datetime, @dateOfBirth), @gender,
@emailAddress, @highSchoolName, @highSchoolGradYear)
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
Would one of you non-newbies be so kind as to straighten me out?
I figure it's my ignorance/syntax issue causing some problem, whether in the
java
callable statement syntax or the stored procedure itself.
Also, a pointer to any documentation that might help me resolve future issues
on my own would be much appreciated.
.
- Follow-Ups:
- Re: Exception comes from where?
- From: Joe Weinstein
- Re: Exception comes from where?
- From: Joe Weinstein
- Re: Exception comes from where?
- Prev by Date: Re: Multiple ResultSets
- Next by Date: Re: Exception comes from where?
- Previous by thread: Re: Multiple ResultSets
- Next by thread: Re: Exception comes from where?
- Index(es):
Relevant Pages
|