开发者

Exception while executing SQL Query using JDBC

开发者 https://www.devze.com 2023-02-10 15:07 出处:网络
I get an exception while executing an sql query using jdbc on NetBeans IDE. I\'m able to execute the same query using Microsoft SQL Server Management Studio Express withou开发者_StackOverflowt any err

I get an exception while executing an sql query using jdbc on NetBeans IDE. I'm able to execute the same query using Microsoft SQL Server Management Studio Express withou开发者_StackOverflowt any errors.

Here is the query:

SELECT tcd.RouterCallKey,adc.AgentSkillTargetID,adc.AgentPeripheralNumber,adc.InstrumentPortNumber,adc.ANI,adc.DateTime,adc.TalkTime 
FROM Termination_Call_Detail tcd 
INNER JOIN 
(
SELECT tcd1.RouterCallKey, AgentSkillTargetID,AgentPeripheralNumber,InstrumentPortNumber,ANI,DateTime,TalkTime
FROM Termination_Call_Detail AS tcd1 WHERE tcd1.AgentSkillTargetID <>'' 
AND tcd1.TalkTime > 0 AND tcd1.TalkTime <=5 AND RouterCallKey <> 0 AND CallDisposition <>28
AND tcd1.DateTime >= '2011-02-03 12:00:00 AM' AND tcd1.DateTime <= '2011-02-03 11:59:59 PM'
) adc 
ON adc.RouterCallKey = tcd.RouterCallKey AND tcd.CallDisposition in (52) 
AND tcd.DateTime >= '2011-02-03 12:00:00 AM' AND tcd.DateTime <= '2011-02-03 11:59:59 PM' 
AND LEN(tcd.ANI ) > 4

Here is the exception:

Incorrect syntax near the keyword 'as'.


There must be a difference between the two queries. Run the SQL Server Profiler to capture the query or do a System.out.println to display the exact query you are running in Java. Look out for things like missing spaces like so:

"SELECT * FROM" +
"WHERE problem = 'No space between from and where'";
0

精彩评论

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