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 9221783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:39:06+00:00 2026-06-18T03:39:06+00:00

I’m working with a prepared statement I’ve generated, and I’m getting a syntax error

  • 0

I’m working with a prepared statement I’ve generated, and I’m getting a syntax error on the statement thrown by java. Yet when i copy and paste the toString of the PS into phpmyadmin for the database, it executes flawlessly. any idea’s what could be wrong, i’m fairly stumped?

edit: changed to ps.executeUpdate(query); still doesn’t work.

public int addOrder(Order order){
    int rs=false;
    try {
        String query = "INSERT INTO `orders`(`orderNumber`, `productNumber`, `quantity`, `orderer`, `assembler`, "
                + "`meshType`, `beadType`, `beadCount`, `notes`, `dateCompleted`, `dateSubmitted`, `isComplete`) "
                +"VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
        PreparedStatement ps = con.prepareStatement(query);
        ps.setString(1, order.getOrderNumber());
        ps.setInt(2, order.getProductNumber());
        ps.setInt(3, order.getQuantity());
        ps.setString(4, order.getOrderer());
        ps.setString(5, order.getAssembler());
        ps.setString(6, order.getMesh());
        ps.setString(7, order.getBeadType());
        ps.setInt(8, order.getBeadCount());
        ps.setString(9, order.getNotes());
        ps.setLong(10, order.getDateCompleted().getTime());
        ps.setLong(11, order.getDateSubmitted().getTime());
        ps.setBoolean(12, order.getIsComplete());
        System.out.println(ps.toString());
        rs = ps.executeUpdate(query);

    } 
    catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return rs;
}

the error message i get, preceded by the ps.toString() from addOrder. and like i said, if i copy paste the relevant part of the toString into phpmyadmin and execute it works fine. any ideas of what i’m doing wrong?

   com.mysql.jdbc.JDBC4PreparedStatement@40378309: INSERT INTO
 `orders`(`orderNumber`, `productNumber`, `quantity`, `orderer`,
 `assembler`, `meshType`, `beadType`, `beadCount`, `notes`,
 `dateCompleted`, `dateSubmitted`, `isComplete`) VALUES
 ('',251,1,'Mark','','Other','LBB',150,'this is a
 test',1357249393009,1357249393010,0)

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(Unknown
Source) at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source) at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at
com.mysql.jdbc.Util.getInstance(Util.java:386) at
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1053) at
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096) at
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028) at
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490) at
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651) at
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2728) at
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2678) at
com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:894) at
com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:732) at
cbs.business.internalorders.Database.addOrder(Database.java:232) at
cbs.business.internalorders.IOGui$1.widgetSelected(IOGui.java:205) at
org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source) at
org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source) at
org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source) at
org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source) at
org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source) at
cbs.business.internalorders.IOGui.(IOGui.java:218) at
cbs.business.internalorders.InternalOrders.main(InternalOrders.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-06-18T03:39:07+00:00Added an answer on June 18, 2026 at 3:39 am

    I finally found my solution, For some reason it didn’t like my setStrings so I set it the long way and got it to work. thank you!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have been unable to fix a problem with Java Unicode and encoding. The
I have thousands of HTML files to process using Groovy/Java and I need to
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.