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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:30:17+00:00 2026-06-09T06:30:17+00:00

I have servlet – @WebServlet(/servlet123) public class servlet123 extends HttpServlet { protected void doPost(HttpServletRequest

  • 0

I have servlet –

@WebServlet("/servlet123")
public class servlet123 extends HttpServlet {


    protected void doPost(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
                String usrID = "111" ; 
            String strAllAccocuntsSQL = "SELECT * (FROM account, account_person) "
                    + "WHERE (account.accountNum = account_person.accountNum"
                    + "AND account_person.personID=? )ORDER BY account.accountNum;";
            PreparedStatement prepareSQL = connection
                    .prepareStatement(strAllAccocuntsSQL);
                        prepareSQL.setString(1, usrID);   
            ResultSet resultWithAccounts = prepareSQL.executeQuery();
    }

}

I check all about connection and it was OK .

When it reach to the line ResultSet resultWithAccounts = prepareSQL.executeQuery(); it throws exception –

 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 'account_person.personID='111' )ORDER BY account.accountNum' 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:4074)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4006)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2468)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2629)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2719)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2318)

The SQL code of the 2 above tables is –

CREATE TABLE  `account_person` (
 `accountNum` INT( 11 ) NOT NULL ,
 `personID` TEXT NOT NULL
)

AND

CREATE TABLE  `account` (
 `accountNum` INT( 11 ) NOT NULL ,
 `dateCreated` DATE NOT NULL ,
 `accountName` TEXT,
 `description` TEXT,
 `statusAccount` TEXT,
 `sumOfMoney` INT( 11 ) NOT NULL DEFAULT  '0'
)

What wrong in the SQL statement in prepareSQL ?

  • 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-09T06:30:20+00:00Added an answer on June 9, 2026 at 6:30 am

    I suspect:

    + "WHERE (account.accountNum = account_person.accountNum"
    + "AND account_person.personID=? )ORDER BY account.account
    

    means you’re concatenating accountNum and AND without an intermediate space. That ties in with the error message.

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

Sidebar

Related Questions

I have a servlet that looks like this: public void doPost(HttpServletRequest request, HttpServletResponse response)
I have this servlet - @WebServlet(/CreateNewPersonServlet) public class CreateNewPersonServlet extends HttpServlet { private void
I have servlet that does the following: public class LoginServlet extends HttpServlet { protected
I have a servlet like this: @WebServlet(/a/path) @WebInitParam(name=name, value=name_value) public class MyServlet extends HttpServlet
I have JoinCustomerToAccountServlet servlet under src/controller - @WebServlet(/JoinCustomerToAccountServlet) public class JoinCustomerToAccountServlet extends HttpServlet {
I have a servlet program. This is my code: public class CompanionProxy extends HttpServlet
I have Servlet that looks something like this: public class MyServlet extends Servlet {
I have a servlet that construct response to a media file request by reading
I have a servlet class which handles login. At the end of my login
I have a Servlet class in which I import javax.servlet.* and javax.servlet.http.* . When

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.