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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:00:43+00:00 2026-06-03T23:00:43+00:00

I am trying to connect to a MySQL database from a jsp page using

  • 0

I am trying to connect to a MySQL database from a jsp page using jdbc in the backend.

I have the following code:

public static void insertIntoDatabase(String code,String name,String temp,String hum,String del) {
    Connection con = null;
    if (del.length() == 0) {
        del="no data";  
    }
    name = name.replaceAll("\\(.+?\\)", "");
    name = name.replaceAll(" ", "_");
    del = del.replaceAll(" ", "_");
    System.out.println("del "+del);

    String url = "jdbc:mysql://localhost:3306/test";

    try {
        Class.forName("com.mysql.jdbc.Driver");
        con = DriverManager.getConnection(url,"root","");
        con.createStatement().executeUpdate("CREATE TABLE IF NOT EXISTS aiportdetails(code VARCHAR(50) PRIMARY KEY, " +
                "name VARCHAR(250), temp VARCHAR(50), hum VARCHAR(50), del VARCHAR(50))");
        ResultSet rs = con.prepareStatement("SELECT * FROM airportdetails;").executeQuery();
    } catch (SQLException ex) {
        ex.printStackTrace();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } finally {
        try {
            if (con != null) {
                con.close();
            }

        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }
}

I am getting the following error at

ResultSet rs = con.prepareStatement(“SELECT * FROM airportdetails;”).executeQuery();

error:

Table ‘test.airportdetails’ doesn’t exist

But from my phpmyadmin I can see that the table is created and exists:
enter image description here
What is the reason I am getting this error?

Thank you.

  • 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-03T23:00:45+00:00Added an answer on June 3, 2026 at 11:00 pm

    executeUpdate()

    Executes the SQL statement in this PreparedStatement object, which must be an SQL INSERT, UPDATE or DELETE statement; or an SQL statement that returns nothing, such as a DDL statement.

    Currently you are trying to use this for creating a table. That’s the reason why you are getting that error.

    Refer to the documentation Java 6 OR Java 1.4.2 for executeUpdate

    EDIT:

    You should create a table using Statement

    Statement st = con.createStatement();
    String table = "Create table .......";
    st.executeUpdate(table);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to connect to mysql database from jsp page. The connection code
I'm trying to connect to MySQL database from node.js using db-mysql library. Everything works
I am trying connect to MySQL database from ASP.net code. some my connection is
I am trying to connect to a remote mysql database from an iPhone. I
I'm trying to connect to a MySQL 5 database using the MySQL ODBC 5.1
I'm trying to connect to remote MySQL server with SSL from PHP using mysql_connect:
I'm trying to connect to a MySQL database using my ASP.NET Web Forms Application.
HI Guys, I have following problem. I'm trying to connect from my Iphone app
I'm trying to insert text into a MySQL DataBase from a form using PHP.
I am trying to connect to a local MySQL database from a VB6 application.

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.