LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-03-2023, 08:02 PM   #1
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,561

Rep: Reputation: 177Reputation: 177
SQL Server The column name is not valid


Normally I'd ask this question on the Micosoft answers forum, but since they now want me to download the Microsoft Authenticator app to my phone, I'm not interested. LQ people seem to know stuff like this so I'll try here.

I'm running Slackware64 14.2, Java 17.0.2 and Tomcat10.0.17.

I'm running a query in java/jsp which is giving me an error:
Code:
select a.allocationAmount, c.totalCredit 
from WTWpreMedicareSvcAmount a 
left join vwWTWpreMedicareServiceCredit c on c.memberId = '123456'
where a.effYear = 2023 and a.serviceCredit = case when c.totalCredit is null then 20 when c.totalCredit > 30 then 30 else c.totalCredit end

Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: The column name totalCredit is not valid.
Yet if I run this query using just java it works:
Code:
select a.allocationAmount, c.totalCredit 
from WTWpreMedicareSvcAmount a 
left join vwWTWpreMedicareServiceCredit c on c.memberId = '123456' 
where a.effYear = 2023 and a.serviceCredit = case when c.totalCredit is null then 20 when c.totalCredit > 30 then 30 else c.totalCredit end

allocationAmount totalCredit
---------------- ----------------------------------------
480.0000
Any idea why I get the column name not valid when run within jsp? I believe both Java and jsp are using sqljdbc42.jar.
 
Old 07-03-2023, 11:49 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,866
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Did you paste the same code twice? Even so, these might be two different databases, only one of them having this field.

Last edited by NevemTeve; 07-04-2023 at 12:29 AM.
 
Old 07-04-2023, 09:39 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
I am with NevemTeve, I see 2 select queries and no java / jsp??
 
Old 07-04-2023, 01:55 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,662
Blog Entries: 4

Rep: Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943
Instinctively, I'd suggest that you look for "a 'DOH!' situation" right about now. Check very carefully that you are in fact presenting an identical query, to the same database, in both (very different ...) situations.

Last edited by sundialsvcs; 07-04-2023 at 01:56 PM.
 
1 members found this post helpful.
Old 07-12-2023, 09:15 AM   #5
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,561

Original Poster
Rep: Reputation: 177Reputation: 177
sundialsvcs was right, "a 'DOH!' situation". I have two ResultSet variables in my program, and this query used the 2nd one, rs2. However, when I went to get the column totalCredit I did rs.getBigDecimal("totalCredit") instead of rs2.getBigDecimal(...). Posting the actual code would probably have helped everyone see my error, but I've become gun-shy of posting code on LQ as I often get such posts rejected.

Anyway, thanks all for the help.
 
Old 07-12-2023, 11:15 PM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,662
Blog Entries: 4

Rep: Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943
("Chuckle ...") Good sir, by now my forehead is perfectly smooth as the result of such physical encounters.

- - -

Shhh!! Don't let them know! They still believe that we are all geniuses!
 
  


Reply

Tags
java, jsp, sql server



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

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to Install SQL Server and SQL Server CLI Tools on Ubuntu LXer Syndicated Linux News 0 02-04-2022 08:09 PM
LXer: Moving with SQL Server to Linux? Move from SQL Server to MySQL as well! LXer Syndicated Linux News 0 11-28-2016 02:02 PM
SMTP Valid Hostname > Reverse DNS is not a valid Hostname ..... Anandhc Linux - Newbie 5 03-30-2016 01:19 PM
[SOLVED] bash: export: `=': not a valid identifier - bash: export: `0': not a valid identifier PClOStinspace Linux - General 4 01-24-2014 01:11 PM
Finding the name and data type of a column in SQL Travis86 Programming 11 08-15-2004 04:20 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration