Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP INSERT statement  RSS feed

 
p guha
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all, I am trying to INSERT data in to database. GOT following error.
The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
java.lang.ArrayIndexOutOfBoundsException
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.clearParameter(JdbcOdbcPreparedStatement.java:1027)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setTimestamp(JdbcOdbcPreparedStatement.java:910)
at com.ora.jsp.sql.SQLCommandBean.setValues(SQLCommandBean.java:197)......
my code:==================================
<%@ page language="java" contentType="text/html" %>
<%@ taglib uri="/orataglib" prefix="ora" %>
<ora:useDataSource id="example"
className="sun.jdbc.odbc.JdbcOdbcDriver"
url="jdbc dbc:example" />
<%--
See if the employee is already defined. If not, insert the
info, else update it.
--%>
<ora:sqlQuery id="empDbInfo" dataSource="example">
SELECT * FROM Customer1
WHERE userName = ?
<ora:sqlStringValue param="userName" />
</ora:sqlQuery>
<% if (empDbInfo.size() == 0) { %>
<ora:sqlUpdate dataSource="example">
INSERT INTO Customer1
(userName,password,firstName,lastName,street,
city,state,zip,phone,email)
VALUES(?,?,?,?,?,?,?,?,?,?)
<ora:sqlStringValue param="userName" />
<ora:sqlStringValue param="passWord" />
<ora:sqlStringValue param="firstName" />
<ora:sqlStringValue param="lastName" />
<ora:sqlStringValue param="street" />
<ora:sqlStringValue param="city"/>
<ora:sqlStringValue param="state"/>
<ora:sqlStringValue param="zip"/>
<ora:sqlStringValue param="phone"/>
<ora:sqlStringValue param="email" />
<ora:sqlTimestampValue value="<%= new java.util.Date() %>" />
</ora:sqlUpdate>
<% } else { %>
<ora:sqlUpdate dataSource="example">
UPDATE Employee
SET Password = ?,
FirstName = ?,
LastName = ?,
Dept = ?,
EmpDate = ?,
EmailAddr = ?,
ModDate = ?
WHERE UserName = ?
<ora:sqlStringValue param="password" />
<ora:sqlStringValue param="firstName" />
<ora:sqlStringValue param="lastName" />
<ora:sqlStringValue param="dept" />
<ora:sqlDateValue param="empDate" pattern="yyyy-MM-dd" />
<ora:sqlStringValue param="emailAddr" />
<ora:sqlTimestampValue value="<%= new java.util.Date() %>" />
<ora:sqlStringValue param="userName" />
</ora:sqlUpdate>
<% } %>
<%-- Get the new or updated data from the database --%>
<ora:sqlQuery id="newEmpDbInfo" dataSource="example" scope="session">
SELECT * FROM Customer1
WHERE userName = ?
<ora:sqlStringValue param="userName" />
</ora:sqlQuery>
<%-- Redirect to the confirmation page --%><ora:redirect page="confirmation.jsp" />

===================end of code
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!