dbTalk Databases Forums  

[BUGS] BUG #2250: JSTL parameterized queries inserting numeric values

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #2250: JSTL parameterized queries inserting numeric values in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ian Moore
 
Posts: n/a

Default [BUGS] BUG #2250: JSTL parameterized queries inserting numeric values - 02-09-2006 , 08:48 AM







The following bug has been logged online:

Bug reference: 2250
Logged by: Ian Moore
Email address: ian.moore (AT) ism-online (DOT) co.uk
PostgreSQL version: 8.0.3
Operating system: Windows XP
Description: JSTL parameterized queries inserting numeric values
Details:

When using the JSTL via JDBC, there is the option to write INSERT/UPDATE
statements with parameters in JSP's.
There is only two types the data parameters can be, a date or a character
varying string.
In most databases, if a character varying string is provided that contains a
numeric value, and this is used to insert/update a numeric field, the driver
will attempt a type conversion to the numeric value of the string and report
errors only if the string is not a valid . However trying this in JSTL,
which only provides support for text or date parameters results in the
following error:

ERROR: column "????" is of type integer but expression is of type character
varying

For the example I am trying, the following table and JSP/JSTL snippet were
used:

-----
create table state_defns(state integer primary key,
description varchar(200));
-----
<sql:update>
INSERT INTO state_defns (state, description)
VALUES (?,?);
<sqlaram value='${param.state}'/>
<sqlaram value='${param.name}'/>
</sql:update>
-----

I have noticed other people trying to do this and have had the same error,
though some have suggested it worked at version 7.1
I have also tried it on version 8.1 (database and jdbc drivers) on linux.

I have used this as a workaround:
<sql:update>
INSERT INTO state_defns (state, description) VALUES (${param.state},?);
<sqlaram value='${param.name}'/>
</sql:update>

but this poses too many security risks from SQL Injection.

I believe this issue is also true for JDBC

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.