any find can tell me how to remove the error that present in picture

enter image description here

package sample;  import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement;  public class DatabaseHelper {     Connection connection;      public DatabaseHelper(Connection connection) {         this.connection = connection;     }     public void createTable()     {         String query = "CREATE TABLE IF NOT EXISTS person(id int primary key unique auto_increment , first_name varchar(55),last_name varchar(55)";         try {             Statement statement = connection.createStatement();             statement.execute(query);              System.out.println("table created");         } catch (SQLException e) {             e.printStackTrace();         }      } } 

the error occurs where I execute the statement. I work to learn MySQL but when I create the table using java code. I found some exceptions kindly tell me which type of error it is and how to remove this error.

Asked on September 1, 2020 in Mysql.
Add Comment
1 Answer(s)

As gaurav-jeswani mentioned there is a missing closing bracket at the end of the create statement. I have added it in the below statement

CREATE TABLE IF NOT EXISTS person(id int primary key unique auto_increment , first_name varchar(55),last_name varchar(55)) 

should work

Answered on September 1, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.