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

  • Home
  • SEARCH
  • 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 8382449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:55:51+00:00 2026-06-09T16:55:51+00:00

I have the following doGet() : protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,

  • 0

I have the following doGet():

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        MysqlDataSource ds = new MysqlConnectionPoolDataSource();
        ds.setServerName("localhost");
        ds.setPort(3306);
        ds.setUser("root");
        ds.setPassword("");
        try {
            Connection connection = null ; 
            connection =  ds.getConnection();
            Statement statement = connection.createStatement();
            // create the DB .. 
            statement.executeUpdate("CREATE DATABASE IF NOT EXISTS "
                            +"testSQLtable" )  ;

            // use DB ..

            statement.executeUpdate("USE testSQLtable") ; 

            // create table ...
            statement.executeUpdate("DROP TABLE IF EXISTS  account "
                    +"CREATE TABLE  account ( "
                     +"accountNum INT( 11 ),"
                     +"dateCreated DATE NOT NULL,"
                     +"accountName TEXT,"
                     +"description TEXT,"
                     +"statusAccount TEXT,"
                     +"sumOfMoney INT( 11 ) NOT NULL DEFAULT  0 );" )  ;
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

The first two executeUpdate of create DB and use him works fine . When in running reach to the line statement.executeUpdate("DROP TABLE IF EXISTS accounnt ....." it throws an 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 'CREATE TABLE  account ( accountNum INT( 11 ),dateCreated DATE NOT NULL,accountNa' 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:2713)
    at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1794)
    at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1712)
    at control.CreateDBinitialServlet.doGet(CreateDBinitialServlet.java:56)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
  • 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-09T16:55:53+00:00Added an answer on June 9, 2026 at 4:55 pm

    This should work in your case:

    statement.executeUpdate("DROP TABLE IF EXISTS  account ");
    statement.executeUpdate("CREATE TABLE  account ( "
                         +"accountNum INT( 11 ),"
                         +"dateCreated DATE NOT NULL,"
                         +"accountName TEXT,"
                         +"description TEXT,"
                         +"statusAccount TEXT,"
                         +"sumOfMoney INT( 11 ) NOT NULL DEFAULT  0 )" )  ;
    

    Cause: Statements can only execute one SQL-Statement with every call of the execute-methods.

    If you want to execute two or more statements simultaneously you can do this with Batch-Jobs.
    Like:

    statement.addBatch("DROP TABLE IF EXISTS  account ");
    statement.addBatch("CREATE TABLE  account ( "
                         +"accountNum INT( 11 ),"
                         +"dateCreated DATE NOT NULL,"
                         +"accountName TEXT,"
                         +"description TEXT,"
                         +"statusAccount TEXT,"
                         +"sumOfMoney INT( 11 ) NOT NULL DEFAULT  0 )" )  ;
    statement.executeBatch();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code... @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
I have the following scala code: package dummy import javax.servlet.http.{HttpServlet, HttpServletRequest => HSReq, HttpServletResponse
I have the following code: String table; private DB.ConnectMAS mas=new DB.ConnectMAS(); java.sql.ResultSet rs1 =
I have the following code: URL urlServlet = new URL(WEB_SERVER_URL); URLConnection connection = urlServlet.openConnection();
I have the following code: $writer = new Zend_Log_Writer_Stream($path./../../../../data/logs/Log.log); $logger = new Zend_Log($writer); $logger->info(print_r($xm1,true));
In a Google Apps Script, I have the following script: function doGet() { return
Hi I have th following Servlet in a new Google App Engine (SDK 1.6.6)
I have following plist: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd>
I have following source. In insertMessage(..), it calls selectMessage to check whether duplicate record
I have following div in a page (I can not modify). <div id=:0.control>Click me</div>

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.