- Kennedy
- Aug 1, 2006
-
hard to breathe?
|
JSTL SQL Insert Query - Kinda fixed
code:<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<sql:setDataSource var ="bookdB" scope = "session" driver = "sun.jdbc.odbc.JdbcOdbcDriver" url = "jdbc:odbc:books" />
<sql:update var = "usersInsert" dataSource ="${bookdB}" scope="request">
INSERT INTO Users (Username, Password, FirstName, Surname, AddressLine1, AddressLine2, City, Telephone, Mobile)
VALUES ('test', "test", 'test', 'test', 'test', 'test', 'test', 1111111, 1111111111)
</sql:update>
<jsp:forward page="test.jsp" />
The above is a test Insert statement using JSTL in a JSP page. As you can see, I'm trying to create a new row in an Access database and fill it with test data. All fields are TEXT apart from the phone numbers which are LONG INTs.
Whenever I run it, I get a
quote:java.sql.SQLException: General error
error. The dataSource is fine, I've copied it from a working query.
Any ideas why I can't get it to work? Running on a Tomcat 6.0.10 server.
EDIT: don't know how, but the INSERT is running fine now. Don't know what I changed to fix it
EDIT 2: Goddamn it, don't know whether it good or not that, after being stuck for an hour or so, I manage to fix my problem with 10 mins of posting. EVERY. TIME.
Fixed statement:
code:<fmt:parseNumber var="telephone" value="${param.telephone}" type="number" />
<fmt:parseNumber var="mobile" value="${param.mobile}" type="number" />
<sql:update var = "Insert" dataSource ="${bookdB}">
INSERT INTO Users (Username, Password, FirstName, Surname, AddressLine1, AddressLine2, City, Telephone, Mobile)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
<sql:param value="${param.username}" />
<sql:param value="${param.password}" />
<sql:param value="${param.firstname}" />
<sql:param value="${param.lastname}" />
<sql:param value="${param.addressline1}" />
<sql:param value="${param.addressline2}" />
<sql:param value="${param.city}" />
<sql:param value="${param.telephone}" />
<sql:param value="${param.mobile}" />
</sql:update>
Kennedy fucked around with this message at 17:00 on Apr 8, 2008
|
#
¿
Apr 8, 2008 16:41
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
May 6, 2024 17:44
|
|
- Kennedy
- Aug 1, 2006
-
hard to breathe?
|
nm
Kennedy fucked around with this message at 16:33 on Nov 29, 2008
|
#
¿
Nov 28, 2008 17:47
|
|