Search code examples
javadatabasederby

How to fix `Encountered <EOF> at line 1 ...` issues


I'm trying to make a derby database in JavaFx project and this error appears to me when I run the project and table is created but I cannot add a row to the table.

Here is the code:

void setupMEMBERTable() 
{
    String TABLE_NAME = "MEMBER";
    try {
        stmt = conn.createStatement();
        DatabaseMetaData dbm = conn.getMetaData();
        ResultSet tables = dbm.getTables(null, null, TABLE_NAME.toUpperCase(), null);
        if (tables.next()) {
            System.out.println("Table" + TABLE_NAME);
        } else {
            stmt.execute("create TABLE MEMBER("
                    +"full_name varchar  (200),"
                    +"address  varchar  (200),"
                    +"mobile  varchar  (200),"
                    +"email varchar(200) primary key ,"
                    +"password  varchar  (200),"
                    +"status boolean default true " + ")"); // Updated
        }
    } catch (SQLException e){
        System.err.println(e.getMessage()+"........SETUP DATABASE");
    } finally { }
}

public ResultSet execQuery(String query) {
    ResultSet result;
    try {
        stmt = conn.createStatement();
        result = stmt.executeQuery(query);
    }
    catch (SQLException ex) {
        System.out.println("Exception at execQuery:dataHandler" + ex.getLocalizedMessage());
        return null;
    }
    finally {
    }
    return result;
}

public boolean execAction(String qu) {
    try {
        stmt = conn.createStatement();
        stmt.execute(qu);
        return true;
    }
    catch (SQLException ex) {
        JOptionPane.showMessageDialog(null, "Error:" + ex.getMessage(), "Error Occurred", JOptionPane.ERROR_MESSAGE);
        System.out.println("Exception at execAction:DataHandler " + ex.getLocalizedMessage());
        return false;
    }
    finally {
    }
}

Error

   Exception at execAction:dataHandler23505 : [0] SQL0000000001-03d30059-0177-5922-d5b6-00001e28fd60, [1] MEMBER

It happens when I try to add a new Member. As you see the query is not executed in execAction(qu) method.
What can I do to solve the problem?


Solution

  • Looks to me like you are missing a ) in the line:

    "status boolean default true <HERE>");
    

    I believe that the Encountered <EOF> at line 1 Exception message is a Syntax Error issued by the database driver, as it is still expecting stuff when it gets to the end of your statement, in your case 177 characters long.