Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7538051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:00:53+00:00 2026-05-30T07:00:53+00:00

I am currently working on a project for school that is a java memo

  • 0

I am currently working on a project for school that is a java memo application. It runs on the model view controller approach to an application so there are many files that each handle certain tasks. When I run my createMemos class i get an sql syntax error. that reads as follows…. Do you see any syntax mistakes?

run:
Model used mysql
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 ')' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
at com.mysql.jdbc.Util.getInstance(Util.java:384)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2562)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1664)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1583)
at models.Memos.createTable(Memos.java:49)
at guimemos.CreateMemos.main(CreateMemos.java:15)
BUILD SUCCESSFUL (total time: 1 second)

my memos class is as follows . .

public class Memos {

    private String table = "memos";
    private String props_file = "models" + java.io.File.separator + table + ".properties";
    private DB db;

    public Memos() throws Exception {
        db = new DB();
    }

    public void createTable() throws Exception {

        Properties table_props = Util.loadFile(props_file);

        String property = DB.getModel() + "." + table;
        String table_def = table_props.getProperty(property);
        if (table_def == null) {
            throw new Exception("no such property: " + property);
        }
        Connection cx = db.connect();

        String sql_op;
        Statement st = cx.createStatement();

        sql_op = "drop table if exists " + table;
        st.executeUpdate(sql_op);

        sql_op = "create table " + table + "(" + table_def + ")";

        st.executeUpdate(sql_op);
    }

    public int insert(Memo memo) throws Exception {
        Connection cx = db.connect();

        PreparedStatement st = cx.prepareStatement(
                "insert into " + table + "(title,timeStamp,content) values (?, ?, ?)");
        st.setString(1, memo.getTitle());
        st.setTimestamp(2, memo.getTimeStamp());
        // st.setString(2, memo.getTimeStamp().toString());
        st.setString(3, memo.getContent());
        st.executeUpdate();

        st = cx.prepareStatement("select max(id) from " + table);
        ResultSet rs = st.executeQuery();
        rs.next();
        int new_id = rs.getInt(1);
        return new_id;
    }

    // fetch all memos
    public List<Memo> fetchAll() throws Exception {
        Connection cx = db.connect();

        String sql_op = "select * from " + table;
        Statement st = cx.createStatement();

        ResultSet rs = st.executeQuery(sql_op);

        List<Memo> L = new LinkedList<Memo>();
        while (rs.next()) {
            int id = rs.getInt("id");
            String title = rs.getString("title");
            String content = rs.getString("content");
            Timestamp timeStamp = rs.getTimestamp("timeStamp");



            Memo memo = new Memo(id, title, timeStamp, content);
            L.add(memo);
        }
        return L;
    }

    // fetch one memo
    public Memo fetch(int id) throws Exception {
        Connection cx = db.connect();
        PreparedStatement st = cx.prepareStatement(
                "select * from " + table + " where id=?");
        st.setInt(1, id);
        ResultSet rs = st.executeQuery();
        if (!rs.next()) {
            return null;
        }
        String title = rs.getString("title");
        String content = rs.getString("content");
        Timestamp timeStamp = rs.getTimestamp("timeStamp");


        Memo memo = new Memo(id, title, timeStamp, content);
        return memo;
    }

    // remove one memo
    public boolean remove(int id) throws Exception {
        Connection cx = db.connect();
        PreparedStatement st = cx.prepareStatement(
                "delete from " + table + " where id=?");
        st.setInt(1, id);
        int num = st.executeUpdate();
        return (num != 0);
    }

    // update one memo
    public void modify(Memo memo) throws Exception {
        Connection cx = db.connect();

        int id = memo.getId();

        PreparedStatement st = cx.prepareStatement("update " + table
                + " set title=?, timeStamp=?, content=?" + " where id=?");

        st.setString(1, memo.getTitle());
        st.setTimestamp(2, memo.getTimeStamp());
        st.setString(3, memo.getContent());
        st.setInt(4, id);
        st.executeUpdate();
    }
}

here is the properties file:

mysql.memos=id integer auto_increment primary key not null,\
title varchar(80) not null,
timeStamp datetime not null,\
content text

sqlite.memos=id integer primary key not null,\
title text not null,\
timeStamp int not null,\
content text

error after adding suggestions

Model used mysql
Attempting to execute SQL: drop table if exists memos
Attempting to execute SQL: create table memos(id integer auto_increment primary key     not null,title varchar(80) not null,)
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 ')' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at   sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39    )
at   sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
at com.mysql.jdbc.Util.getInstance(Util.java:384)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2562)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1664)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1583)
at models.Memos.createTable(Memos.java:50)
at guimemos.CreateMemos.main(CreateMemos.java:15)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:00:55+00:00Added an answer on May 30, 2026 at 7:00 am

    It looks like something is wrong with table_def in this statement:

    sql_op = "create table " + table + "(" + table_def + ")";
    st.executeUpdate(sql_op);
    

    You’re reading it from a properties file though, so we’ll need to actually see it to know what’s wrong. I’d try changing it to this:

    sql_op = "create table " + table + "(" + table_def + ")";
    System.out.println("Attempting to execute SQL: " + sql_op);
    st.executeUpdate(sql_op);
    

    And then let us know what the output is.

    EDIT: The problem is this section:

    mysql.memos=id integer auto_increment primary key not null,\
    title varchar(80) not null,
    timeStamp datetime not null,\
    content text
    

    Note the lack of a \ on the second line. That’s causing your property to be cut off, so you lose the timeStamp and content lines, and it’s a syntax error since there’s a trailing ,.

    Try changing to this:

    mysql.memos=id integer auto_increment primary key not null,\
    title varchar(80) not null,\
    timeStamp datetime not null,\
    content text
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java web application I’m developing for a school project. There’s a
I am currently working on a project that is moving from .NET 2.0 to
I'm currently working on a project for medical image processing, that needs a huge
I am currently working on a project that will store specific financial information about
I'm currently working on a school project in Eclipse (We have just started using
im currently working on a project that involves listing contacts with a photo and
I am currently working on a project where I have several string that may
I am currently working on a project in java. I need to create a
I'm currently working on some school project; we are developing a simple RPG, but
I'm currently working on a school (matrix multiplier) project and I have a problem.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.