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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:31:02+00:00 2026-05-28T01:31:02+00:00

I have a Java Web Application where my clients connect to the Web Service

  • 0

I have a Java Web Application where my clients connect to the Web Service to update a MySQL database (using JDBC) with their data. What i want to do is to check wether the requested table exists without using MetaData every time a client connects and uses an operation of the Web Service. I thought of just executing INSERT every time and the first client that connects to the web service will cause an SQLException that i will catch, look at its ErrorCode to decide wether it is caused by nonexistant table and if that’s the case it will (inside the catch clause) create the table, insert the data that couldn’t be inserted earlier because of the Exception and then create a thread to handle that particular client (e.g. check that it will refresh its entry in the database every x seconds). Will this implementation do the job? Is the thread going to run properly and everything, even though it will be started inside the catch clause of an Exception?

  • 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-28T01:31:03+00:00Added an answer on May 28, 2026 at 1:31 am

    Doing it the way you describe will tie your application to MySQL, since the exceptions that come back will have to be examined as MySQL specific to determine if they are caused by a missing table and not some other problem. Most developers consider it bad practice to tie an application to a specific database like this.

    Also, if you get 2 requests for the same non-existent table at once, you could very likely get 2 threads attempting to create the same table and one of them will get an error trying to create a table that already exists, so you would need to do some kind of synchronization.

    I suggest that you re-examine your application design so that all tables exist in advance. If they absolutely must be created dynamically, I would create a singleton object that used MetaData to determine existence of each table and then cache that knowledge in the object itself so that you only need to search for existence of each table once per life of the web application. You could also synchronize the methods on this object to prevent 2 threads from attempting to create the same table at once.

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

Sidebar

Related Questions

We have a java web service application that uses log4j to do logging. An
I have a Java based web-application using Java Server Faces and Facelets. I am
I have a Java-JSF Web Application on GlassFish, in which I want to use
I have a Java web application leveraging JPA. The database instance is specified in
I want to connect to a my facebook application using the facebook java api
I have a fairly standard Java EE6 web application using JPA 2 with dependency
I have a Java web application at my work and I'd like simplify how
I have a Java Web Start application. I specify the resource (jars, images, etc)
Is it possible to have a Java/J2EE web application integrate/communicate with SharePoint to load,
In a Java web application I have a recurring message load of type A

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.