You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM CHARACTER SET utf8
' at line 29 SQL=CREATE TABLE jos_banner
( bid
int(11) NOT NULL auto_increment, cid
int(11) NOT NULL default '0', type
varchar(30) NOT NULL default 'banner', name
varchar(255) NOT NULL default '', alias
varchar(255) NOT NULL default '', imptotal
int(11) NOT NULL default '0', impmade
int(11) NOT NULL default '0', clicks
int(11) NOT NULL default '0', imageurl
varchar(100) NOT NULL default '', clickurl
varchar(200) NOT NULL default '', date
datetime default NULL, showBanner
tinyint(1) NOT NULL default '0', checked_out
tinyint(1) NOT NULL default '0', checked_out_time
datetime NOT NULL default '0000-00-00 00:00:00', editor
varchar(50) default NULL, custombannercode
text, catid
INTEGER UNSIGNED NOT NULL DEFAULT 0, description
TEXT NOT NULL DEFAULT '', sticky
TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, ordering
INTEGER NOT NULL DEFAULT 0, publish_up
datetime NOT NULL default '0000-00-00 00:00:00', publish_down
datetime NOT NULL default '0000-00-00 00:00:00', tags
TEXT NOT NULL DEFAULT '', params
TEXT NOT NULL DEFAULT '', PRIMARY KEY (bid
), KEY viewbanner
(showBanner
), INDEX idx_banner_catid
(catid
) ) TYPE=MyISAM CHARACTER SET utf8
很顯然,拋出錯誤時MySQL執行的並不是你給出的這一句SQL。有可能是你在"外調"(樓主你在另一個帖子中的說法)時寫錯了保存SQL查詢語句的變量。
可以echo一下你的sql語句,有可能是內容字段的值中包含sql中有特殊用途的符號,如英文半角單引號“''”(內容中的html標簽屬性值的引號會導致這樣的錯誤)
語法錯誤,檢查near後面的部分
關於You have an error in your SQL syntax; check the manual that corresponds..的解決
代碼如下:
pstmt = conn.prepareStatement("insert into column(columnTitle) values( )"); pstmt.setString(1, column.getColumnTitle());
執行這個插入語句的時候,出現以下錯誤信息:
引用
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'column(columnTitle) values(' ¨± … ')' at line 1
一直把問題定位為插入語句的語法有問題,查找的時候也是往這個方向查,以至於對於網上說的”關鍵字引用錯誤”之類的解決方法直接無視,19x19 後來終於看到有個同學跟我用了同樣一個關鍵字“column”作為表名,問題解決,呃~為了防止再犯這樣的錯誤,貼上mysql關鍵字列表:
ADD ALL ALTER
ANALYZE AND AS
ASC ASENSITIVE BEFORE
BETWEEN BIGINT BINARY
BLOB BOTH BY
CALL CASCADE CASE
CHANGE CHAR CHARACTER
CHECK COLLATE COLUMN
CONDITION CONNECTION CONSTRAINT
CONTINUE CONVERT CREATE
CROSS CURRENT_DATE CURRENT_TIME
CURRENT_TIMESTAMP CURRENT_USER CURSOR
DATABASE DATABASES DAY_HOUR
DAY_MICROSECOND DAY_MINUTE DAY_SECOND
DEC DECIMAL DECLARE
DEFAULT DELAYED DELETE
DESC DESCRIBE DETERMINISTIC
DISTINCT DISTINCTROW DIV
DOUBLE DROP DUAL
EACH ELSE ELSEIF
ENCLOSED ESCAPED EXISTS
EXIT EXPLAIN FALSE
FETCH FLOAT FLOAT4
FLOAT8 FOR FORCE
FOREIGN FROM FULLTEXT
GOTO GRANT GROUP
HAVING HIGH_PRIORITY HOUR_MICROSECOND
HOUR_MINUTE HOUR_SECOND IF
IGNORE IN INDEX
INFILE INNER INOUT
INSENSITIVE INSERT INT
INT1 INT2 INT3
INT4 INT8 INTEGER
INTERVAL INTO IS
ITERATE JOIN KEY
KEYS KILL LABEL
LEADING LEAVE LEFT
LIKE LIMIT LINEAR
LINES LOAD LOCALTIME
LOCALTIMESTAMP LOCK LONG
LONGBLOB LONGTEXT LOOP
LOW_PRIORITY MATCH MEDIUMBLOB
MEDIUMINT MEDIUMTEXT MIDDLEINT
MINUTE_MICROSECOND MINUTE_SECOND MOD
MODIFIES NATURAL NOT
NO_WRITE_TO_BINLOG NULL NUMERIC
ON OPTIMIZE OPTION
OPTIONALLY OR ORDER
OUT OUTER OUTFILE
PRECISION PRIMARY PROCEDURE
PURGE RAID0 RANGE
READ READS REAL
REFERENCES REGEXP RELEASE
RENAME REPEAT REPLACE
REQUIRE RESTRICT RETURN
REVOKE RIGHT RLIKE
SCHEMA SCHEMAS SECOND_MICROSECOND
SELECT SENSITIVE SEPARATOR
SET SHOW SMALLINT
SPATIAL SPECIFIC SQL
SQLEXCEPTION SQLSTATE SQLWARNING
SQL_BIG_RESULT SQL_CALC_FOUND_ROWS SQL_SMALL_RESULT
SSL STARTING STRAIGHT_JOIN
TABLE TERMINATED THEN
TINYBLOB TINYINT TINYTEXT
TO TRAILING TRIGGER
TRUE UNDO UNION
UNIQUE UNLOCK UNSIGNED
UPDATE USAGE USE
USING UTC_DATE UTC_TIME
UTC_TIMESTAMP VALUES VARBINARY
VARCHAR VARCHARACTER VARYING
WHEN WHERE WHILE
WITH WRITE X509
XOR YEAR_MONTH ZEROFILL
如果回答對您有幫助,請采納