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...
精彩评论