ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.