about use spring jdbcTemplate.queryForList

218 views
Skip to first unread message

john...@gmail.com

unread,
Aug 13, 2007, 11:44:05 AM8/13/07
to H2 Database
when i use Spring jdbcTemplate.queryForList() to search H2
data,return result like this:list=[{USERID=admin, USERNAME=manager}],
but i need result like this :list=[{userid=admin, username=manager}],
Whether have what allocation can attain my request?

Thomas Mueller

unread,
Aug 13, 2007, 4:10:55 PM8/13/07
to h2-da...@googlegroups.com
Hi,

This is just a wild guess, but maybe 'userid' and 'username' are
column names? Did you use MySQL or PostgreSQL before, and it's lower
case there? The SQL standard says identifiers should be converted to
uppercase if not quoted, and H2 (and many other databases) do that
that (but not MySQL and PostgreSQL). If this is the case, solutions
would be: create the table using quoted lowercase identifiers: CREATE
TABLE "abc"("userid" INT,...)

If it's not this problem, I suggest you ask in the Spring forum.

Thomas

john...@gmail.com

unread,
Aug 14, 2007, 10:49:10 AM8/14/07
to H2 Database
thank you Thomas Mueller
i use [create table testtbl( "tid" varchar(30) null)] can get result
like =[{tid=admin}], but it have new problem: if i need insert data to
this table, need write sql like this:
insert table testtbl("tid") values('a');
if use
insert into testtbl (tid) values('a')
Column TID not found [42S22-55]
...
so it has new problem...-_-#..


On 8月14日, 上午4时10分, "Thomas Mueller" <thomas.tom.muel...@gmail.com>
wrote:


> Hi,
>
> This is just a wild guess, but maybe 'userid' and 'username' are
> column names? Did you use MySQL or PostgreSQL before, and it's lower
> case there? The SQL standard says identifiers should be converted to
> uppercase if not quoted, and H2 (and many other databases) do that
> that (but not MySQL and PostgreSQL). If this is the case, solutions
> would be: create the table using quoted lowercase identifiers: CREATE
> TABLE "abc"("userid" INT,...)
>
> If it's not this problem, I suggest you ask in the Spring forum.
>
> Thomas
>

> On 8/13/07, johnh...@gmail.com <johnh...@gmail.com> wrote:
>
>
>
>
>
> > when i use Spring jdbcTemplate.queryForList() to search H2
> > data,return result like this:list=[{USERID=admin, USERNAME=manager}],
> > but i need result like this :list=[{userid=admin, username=manager}],

> > Whether have what allocation can attain my request?- 隐藏被引用文字 -
>
> - 显示引用的文字 -

Thomas Mueller

unread,
Aug 14, 2007, 1:23:57 PM8/14/07
to h2-da...@googlegroups.com
Hi,

> I need write sql like this:


> insert table testtbl("tid") values('a');

Yes.

> if use
> insert into testtbl (tid) values('a')
> Column TID not found [42S22-55]

The reason is, unquoted names are converted to uppercase according to
the ANSI SQL-92 standard. H2 supports the ANSI SQL-92 standard, so it
must say 'Column not found'. If it is absolutely required it could be
implemented in the MySQL / PostgreSQL compatibility layer.

> so it has new problem

I understand, but why do you need to use 'insert into testtbl (tid)
values('a')'? Why not 'insert table testtbl("tid") values('a')'?

Thanks,
Thomas

john...@gmail.com

unread,
Aug 15, 2007, 2:29:47 AM8/15/07
to H2 Database
> I understand, but why do you need to use 'insert into testtbl (tid)
> values('a')'? Why not 'insert table testtbl("tid") values('a')'?
because i already had a web application base for Sybase Database , and
i want to change db to H2, So I don't really want to reform the SQL
operation in the original application.
Certainly this is also because of my application oneself design hour
have no in consideration of many database transplant.

Many thanks Thomas Mueller the so warmhearted help , give me a lot of
helps. ^L^

On 8月15日, 上午1时23分, "Thomas Mueller" <thomas.tom.muel...@gmail.com>
wrote:


> Hi,
>
> > I need write sql like this:
> > insert table testtbl("tid") values('a');
>
> Yes.
>
> > if use
> > insert into testtbl (tid) values('a')
> > Column TID not found [42S22-55]
>
> The reason is, unquoted names are converted to uppercase according to
> the ANSI SQL-92 standard. H2 supports the ANSI SQL-92 standard, so it
> must say 'Column not found'. If it is absolutely required it could be
> implemented in the MySQL / PostgreSQL compatibility layer.
>
> > so it has new problem
>

> Thanks,
> Thomas

Thomas Mueller

unread,
Aug 17, 2007, 12:56:04 PM8/17/07
to h2-da...@googlegroups.com
Hi,

I will add a feature request:

"In the MySQL and PostgreSQL, use lower case identifiers by default
(DatabaseMetaData.storesLowerCaseIdentifiers = true)"

However I think the current behavior will be still the default.

Thomas

Reply all
Reply to author
Forward
0 new messages