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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:21:01+00:00 2026-05-25T19:21:01+00:00

Context: MySQL server deployed with MysqldResource java class (Connector/MXJ lib). They app using mysql

  • 0

Context: MySQL server deployed with MysqldResource java class (Connector/MXJ lib). They app using mysql server may crash for some reason and could be finished without shutting down the MySQL.

The setup and run of MySQL done as following:

mr = new MysqldResource(runtimeDir, dataDir);
mr.start("My MySQL", options);

Goal: Write code to ensure that MySQL is not running (MysqldResource.pid doesn’t exist, or pid doesn’t exist). If MySQL I would like to kill it.

Note: I am not going to start mysqld!

Finally,

How do I archieve the Goal using MysqldResource interface, is it even possible? Or I should workout with .pid file for that manually?

In particular will the following code work correctly for me:

mr = new MysqldResource(runtimeDir, dataDir);
mr.shutdown();

assuming its running after in another session after program crashed and without starting mysql first? In other words, will this code kill existing MySQL instance running?

  • 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-25T19:21:02+00:00Added an answer on May 25, 2026 at 7:21 pm

    The following code will work:

    mr = new MysqldResource(runtimeDir, dataDir);
    mr.shutdown();
    

    It works even if it’s running on another VM or with another mr instance. Also following method can be used to check if the MySQL deployed is running:

    mr.isRunning();
    

    To proof that shutdown also works even if called on newly created mr instance check the shutdown code – it uses pidFile() to check the existence of process:

     /**
      * Kills the MySQL process.
      */
        public synchronized void shutdown() {
            boolean haveShell = (getShell() != null);
            if (!pidFile().exists() && !haveShell) {
                printMessage("Mysqld not running. No file: " + pidFile());
                return;
            }
            printMessage("stopping mysqld (process: " + pid() + ")");
    
            issueNormalKill();
    
            if (processRunning()) {
                issueForceKill();
            }
    
            if (shellRunning()) {
                destroyShell();
            }
            setShell(null);
    
            if (processRunning()) {
                printWarning("Process " + pid + "still running; not deleting " 
                        + pidFile());
            } else {
                threads.pause(150);
                System.gc();
                threads.pause(150);
                pidFile().deleteOnExit();
                pidFile().delete();
                pidFile = null;
                pid = null;
            }
    
            setReadyForConnection(false);
    
            printMessage("clearing options");
            options.clear();
            out.flush();
    
            printMessage("shutdown complete");
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Context: A Java client-side application needs to access a server-side MySQL database. Need: Limit
I have a web application deployed on path /var/lib/tomcat6/webapps/abc/</code> in server.xml on path /etc/tomcat/server.xml
I am using Tomcat server in java and wanted to be able to access
I have a problem with Hibernate (3.6.0.-Final) in my Java EE application using MySQL
<%@ WebHandler Language=C# Class=SITEIMPORT %> using System; using System.Web; using MySql.Data; using MySql.Data.MySqlClient; ///
Context: I have a WPF App that uses certain unmanaged DLLs in the D:\WordAutomation\MyApp_Source\Executables\MyApp
in context of SQL Server 2005, I have a table for which the primary
I'm trying start java application but in browser i see standard tomcat's page. Server
I'm migrating some stuff from one mysql server to a sql server but i
I am using EDMX with MySql 5.1. It is working fine except When I

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.