简体   繁体   中英

Creating a table using mysql, jdbc

I have made connections and statement in my java program. When i try to execute the below statement it throws me and error

String details;
details="create table details(ID INTEGER,Name VARCHAR(255),Department VARCHAR(255))";
st.executeUpdate(details);

error

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 'details(a INTEGER,name VARCHAR(255),id INTERGER)' 
at line 1

Explain how to solve the error?

Your code doesn't appear to correspond to the error message. The problem with the error message code is the spelling mistake INTERGER rather than INTEGER.

I tested your code & it runs fine & then replaced it with the code from the error message with spelling corrected & that ran OK too from MySQL workbench.

create table details(a INTEGER,name VARCHAR(255),id INTEGER);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM