开发者

The column name CATALOGNO is not valid. SQL server exception

开发者 https://www.devze.com 2023-03-27 07:48 出处:网络
I have a JAVA method that executes the followi开发者_运维知识库ng query to SQL server database

I have a JAVA method that executes the followi开发者_运维知识库ng query to SQL server database

SELECT  [CHEMICAL_NAME],
        [CHEMI_UNIT],
        [PRICE],
        [VENDOR],
        [CATEGORY]
FROM [RPS].[dbo].[Chemicals]
WHERE CATALOGNO = '" + catNo+"' ;";

Following are the column names of the database table

CATALOGNO,
CAS_NO,
CHEMICAL_NAME,
CHEMI_UNIT,
PRICE,
VENDOR,
CATEGORY,

I get the above mentioned error

com.microsoft.sqlserver.jdbc.SQLServerException: The column name CATALOGNO is not valid.

The query by itself executes perfectly fine when I run it from SQL server query window.


try to use full-qualified column name:

SELECT [CHEMICAL_NAME],[CHEMI_UNIT],[PRICE],[VENDOR],[CATEGORY]FROM [RPS].[dbo].[Chemicals]where [RPS].[dbo].[Chemicals].[CATALOGNO] = '" + catNo+"' ;";

But I'm not sure it helps...

0

精彩评论

暂无评论...
验证码 换一张
取 消