简体   繁体   中英

Im having problems with geting data from MySQL to my java project

I am trying to make a project in java but I'm having problems with MySQL, after trying to get the material inside the table I get this error message:

java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'table' at line 1

String sql = "SELECT Name, OS, Disk, Office, Serialnomain, Serialnotast, Serialnoscreen, Serialnomouse FROM table ";
ResultSet rs = stmt.executeQuery(sql);

table is a reserved word in mariadb

so rename your table and it will run

The SQL Language has some keywords which you should not use in your statement, table is one of them just rename your table to myTable

Change your name from table to anything else and will work fine.

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