Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
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

Adbot
ADBOT LOVES YOU

Kennedy
Aug 1, 2006


hard to breathe?
nm

Kennedy fucked around with this message at 16:33 on Nov 29, 2008

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply