views:

45

answers:

2

I am trying to combine two columns in SQL query but getting the following exception in java.sql.ResultSet's FindColumn method:

JdbcSqlException: The column name FullName is not valid. Column: 'FullName'

Here is my SQL query

SELECT U.FirstName + ' ' + U.LastName AS FullName FROM User as U

Anyone?

Please note that query runs fine when I run it directly in SQL Server management studio. Also, this query is part of a big query that's why U as alias.

A: 

You might try putting parentheses around the string concatenation, as in

SELECT (U.FirstName + ' ' + U.LastName) AS FullName FROM User U

Share and enjoy.

Bob Jarvis
Thanks, but didn't work :(
Jahanzeb Farooq
+1  A: 

When you put "AS FullName", Fullname is a label now. JDBC gets data by "column name" or "field name". You have to change your code (I dont know your prog. language) accordingly.

Burçin Yazıcı