Tag Archives: com.alibaba.druid.sql.parser.ParserException

com.alibaba.druid.sql.parser.ParserException: syntax error

Remember a simple mistake.

sql.append("select"
+"a.MEMBER_NAME, b.ACTION_NAME"
+"from CLUB_MEMBER a,CLUB c, MEMBER_ACTION_RECORD d");
sql.append("WHERE a.CLUB_MEMBER_ID = d.CLUB_MEMBER_ID"
				+ "AND a.CLUB_ID = b.CLUB_ID"
				+ "AND d.ACTION_ID = ?"); 

It’s wrong, why is it wrong? No spaces, SQL prints.
selecta.MEMBER_NAME, b.ACTION_NAMEfrom CLUB_MEMBER a,CLUB c, MEMBER_ACTION_RECORD dWHERE a.CLUB_MEMBER_ID = d.CLUB_MEMBER_IDAND a.CLUB_ID = b.CLUB_IDAND d.ACTION_ID = ?
Now you know why it’s wrong, right?
Correct Codes.

sql.append("select"
+" a.MEMBER_NAME, b.ACTION_NAME"
+" from CLUB_MEMBER a,CLUB c, MEMBER_ACTION_RECORD d");
sql.append(" WHERE a.CLUB_MEMBER_ID = d.CLUB_MEMBER_ID"
				+ " AND a.CLUB_ID = b.CLUB_ID"
				+ " AND d.ACTION_ID = ?"); 

It doesn’t seem to make a big difference, but it’s enough to take half an hour and patience to look at the code.