Forums Register Login
JSP INSERT statement
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.
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"
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" />
<% if (empDbInfo.size() == 0) { %>
<ora:sqlUpdate dataSource="example">
<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() %>" />
<% } 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" />
<% } %>
<%-- 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" />
<%-- Redirect to the confirmation page --%><ora:redirect page="confirmation.jsp" />

===================end of code
<ora:sqlTimestampValue value="<%= new java.util.Date() %>" />
is the problem.
Try new java.sql.Date()
java.util.Date().toString() formats in a way that Oracle cannot understand.
Even better, you might want to pass the Date object directly instead of putting a string inside a scriptlet, then having Oracle convert the String back to a date. (I don't know how to do that with this tag library though. It may not be possible if the tag library only accepts String objects).
When passing the timestamp as a String (inside a <%= ... %> , you run the risk of sending the date formatted in a different Locale than how the database is set up to receive the date. You might want to just use a string formatted as 'DD-MON-YYYY'.
I got following error when i change to new java.sql.Date()
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 35 in the jsp file: /store.jsp
Generated servlet error:
C:\jakarta-tomcat-4.0\work\Standalone\localhost\BankApp\store$jsp.java:455: No constructor matching Date() found in class java.sql.Date.
_jspx_th_ora_sqlTimestampValue_0.setValue( new java.sql.Date() );
if i hard coded the date 02/02/2002 will give me following error=======
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
org.apache.jasper.JasperException: Unable to convert string '02/02/2001' to class java.util.Date for attribute value: java.lang.IllegalArgumentException: Property Editor not registered with the PropertyEditorManager
at org.apache.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager(JspRuntimeLibrary.java:749)
at org.apache.jsp.store$jsp._jspService(store$jsp.java:455)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

All times above are in ranch (not your local) time.
The current ranch time is
Nov 20, 2017 16:12:35.