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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:52:53+00:00 2026-05-20T10:52:53+00:00

My Java program seems to hang after I run it using Windows shell. I

  • 0

My Java program seems to hang after I run it using Windows shell. I dont understand how to solve this error:

C:\quadrantRDBTemplate>java -cp iucbrf.jar;mysql-connector-java-5.0.jar edu.indi
ana.iucbrf.examples.quadrantRDBTemplate.QuadrantTestClassRDB > log.txt
Exception in thread "Thread-3" java.lang.RuntimeException: java.lang.RuntimeExce
ption: java.io.EOFException
        at edu.indiana.util.Base64Tools.decode(Base64Tools.java:58)
        at edu.indiana.iucbrf.feature.featurespec.FeatureSpecRDB.setAllFeatureSp
ecShellsIntoCache(FeatureSpecRDB.java:238)
        at edu.indiana.iucbrf.feature.featurespec.FeatureSpecRDB.readFeatureSpec
RDBIntoCache(FeatureSpecRDB.java:201)
        at edu.indiana.iucbrf.feature.featurespec.FeatureSpecRDB.doThreadedOpera
tion(FeatureSpecRDB.java:189)
        at edu.indiana.util.multithreaded.DBLoaderThread.run(DBLoaderThread.java
:57)
        at java.lang.Thread.run(Unknown Source)

Edit:
Here is the 2 files source code part that I modified to access MySQL, others are the untouched:

QuadrantSystemRDB.java

package edu.indiana.iucbrf.examples.quadrantRDBTemplate;

import edu.indiana.iucbrf.feature.FeatureKey;
import edu.indiana.iucbrf.maintenance.NullMaintenance;
import edu.indiana.iucbrf.retrieval.Retrieval;
import edu.indiana.iucbrf.retrieval.kNN;
import edu.indiana.iucbrf.adaptation.DistanceWeightedAdapter;
import edu.indiana.iucbrf.performancemonitor.PerformanceMonitor;
import edu.indiana.iucbrf.problem.ProblemGenerator;
import edu.indiana.iucbrf.casepackage.CaseGenerator;
import edu.indiana.iucbrf.casebase.FlatCaseBase;
import edu.indiana.iucbrf.cbrsystem.CBRSystem;
import edu.indiana.util.distribution.UniformDistribution;
import java.util.HashMap;
import java.sql.Driver;

import java.sql.DriverManager;  
import java.sql.Connection;     
import java.sql.SQLException;   
import java.util.Map;  

import edu.indiana.iucbrf.casebase.RDBCaseBase;
import edu.indiana.iucbrf.feature.featurespec.FeatureSpecCollection;
import edu.indiana.iucbrf.feature.FeatureCollection;
import edu.indiana.iucbrf.feature.featurespec.FeatureSpecRDBInfo;
import edu.indiana.util.db.JDBCDriverInfo;
import edu.indiana.iucbrf.casebase.RDBCaseBaseInfo;
import edu.indiana.iucbrf.domain.DBInfo;



public class QuadrantSystemRDB
    extends CBRSystem {

    ///////////////////////////////////////////////////////////////////////////
    // Database configuration
    public static final String USERNAME;
    public static final String PASSWORD;
    //public static final String HOST_NAME;
    //public static final String SERVICE_NAME;

    /* Set the above variables appropriately for your database configuration.  Additional
     * code modifications may also be necessary depending on your configuration.
     */
    static {
        //if (true)
        //    throw new UnsupportedOperationException("\n\n*************** NOTICE ***************\nThis exception is expected!  You must set a few constants in QuadrantSystemRDB, according to your database configuration, and then comment out this exception.");
         USERNAME = "root";
         PASSWORD = "123456";
        // HOST_NAME = "localhost";
        // SERVICE_NAME = "";
    }
    ///////////////////////////////////////////////////////////////////////////

    /** The number of cases to be in the case base.  Of course, performance of
     *  the system depends on how many cases are available.
     */
    private static final int NUM_CASES = 5;

    /** The keys to the two problem features. */
    private FeatureKey xKey;
    private FeatureKey yKey;
    DBInfo dbInfo;
    FeatureSpecRDBInfo problemSpecInfo;
    FeatureSpecRDBInfo solutionSpecInfo;
    RDBCaseBaseInfo rdbCasebaseInfo;

    /** Creates a new instance of QuadrantSystem */
    public QuadrantSystemRDB() {

        //Defines the required info classes
        //setupInfo();
        try {
            setupInfo();
            }
            catch (java.sql.SQLException e) {
             // you may want to do something useful here
             // maybe even throw new RuntimException();
            }


        // Define the domain, which describes the type of problems the system will solve.
        setupDomain();

        // Create the case base and add cases to it.
        setupCaseBase();

        // Do no maintenance for this system
        setMaintenance(new NullMaintenance());

        // Retrieval will be 5-nearest neighbor
        Retrieval retrieval = new kNN(getDomain().getProblemDifferentiator(), 5);
        setRetrieval(retrieval);

        // The adaptation technique is a distance-weighted majority vote.
        setAdaptation(new DistanceWeightedAdapter("edu.indiana.iucbrf.adaptation.WeightedMajorityAdapter"));

        // Track the system performance with the performance monitor
        setPerformanceMonitor(new PerformanceMonitor());
    }

    private void setupInfo() throws SQLException
    {
        Driver driver = new com.mysql.jdbc.Driver();

        String url = "jdbc:mysql://localhost:3306/hpdata";
        String username = USERNAME;
        String password = PASSWORD;
        String problemFeatureSpecTableName = "ProblemFeatureSpec";
        String solutionFeatureSpectTableName = "SolutionFeatureSpec";
        String classTableName = "Class";
        String extraDataTableName = "ExtraData";
        String casebaseTablename = "CaseBase";
        String problemTableName = "Problem";
        String solutionTableName = "Solution";
        String inactiveContextsTableName = "InactiveContext";
        String constantsTableName = "Constants";
        dbInfo = new DBInfo(new JDBCDriverInfo(driver, url, username, password),constantsTableName);
        problemSpecInfo = new FeatureSpecRDBInfo(problemFeatureSpecTableName, classTableName, extraDataTableName);
        solutionSpecInfo = new FeatureSpecRDBInfo(solutionFeatureSpectTableName, classTableName, extraDataTableName);
        rdbCasebaseInfo = new RDBCaseBaseInfo(casebaseTablename, solutionTableName, problemTableName, inactiveContextsTableName);
    }


    // Define the domain, which describes the type of problems the system will solve.
    private void setupDomain() {
        QuadrantDomainRDB domain = new QuadrantDomainRDB(dbInfo, problemSpecInfo, solutionSpecInfo);

        /* Add the two problem features: x and y.  The textual description,
         * type, and similarity weight are specified.  The return values are keys
         * that will be referred to in additional setup steps.
         */

        long start, end, totalTime;
        start = System.currentTimeMillis();
        xKey = domain.addProblemFeature("x", "edu.indiana.iucbrf.feature.DoubleFeature", 1, true);
        end = System.currentTimeMillis();
        totalTime = end - start;
        System.out.println("Total Time to add a featurespec: " + totalTime + " in millisec");


        FeatureSpecCollection fsc = domain.getFeatureSpecCollection(FeatureCollection.PROBLEM_FEATURE_COLLECTION);
        start = System.currentTimeMillis();
        fsc.getFeatureSpec(xKey);
        end = System.currentTimeMillis();
        totalTime = end - start;
        System.out.println("Total Time to get a featurespec: " + totalTime + " in millisec");

        yKey = domain.addProblemFeature("y", "edu.indiana.iucbrf.feature.DoubleFeature", 1, true);

        /* Add the solution feature: quadrant.  A key is assigned, but it is not
         * needed at this time.
         */

        domain.addSolutionFeature("Quadrant", "edu.indiana.iucbrf.feature.IntegerFeature");

        /* The reference solution for this domain requires the xKey and yKey.  See
         introductory paper for details on reference methods. */

        domain.prepareReferenceSolution(xKey, yKey);

        setDomain(domain);

    }

    /** The case base must be populated.  For this example, random generation is
     *  possible and sufficient.
     */
    private void setupCaseBase() {

        // The case generator can be built from the problem generator.
        CaseGenerator cg = new CaseGenerator(constructProblemGenerator(), getDomain());

        /** Construct the case base, with a simple flat structure.  For this
         * constructor, the case generator and the desired number of initial cases
         * can be passed.
         */
        long start;
        long end;
        long totalTime;
        start = System.currentTimeMillis();
        setCB(new RDBCaseBase(getDomain(), rdbCasebaseInfo, cg, NUM_CASES));
        end = System.currentTimeMillis();
        totalTime = end - start;
        System.out.println("Total Time to setup casebase with " + NUM_CASES + " : " + totalTime + " in millisec");
    }

    /**  A problem generator requires specification of arguments to send to
     * feature constructors.  Here, random distributions are used.
     */


    public ProblemGenerator constructProblemGenerator() {
        HashMap argMap = new HashMap(2);
        argMap.put(xKey, new UniformDistribution(-1, 1));
        argMap.put(yKey, new UniformDistribution(-1, 1));

        return new ProblemGenerator(argMap, getDomain());
    }
}

QuadrantTestClassRDB.java

package edu.indiana.iucbrf.examples.quadrantRDBTemplate;

import edu.indiana.iucbrf.problem.Problem;
import java.sql.Driver;
import java.io.IOException;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.Statement;

/**
 * This class contains a simple main method that constructs a QuadrantSystemRDB
 * and tests it on a single problem.  This demonstrates basic database functionality.
 * In order to run this program, you will need to configure your database
 * (edu/creation_script.sql may be helpful in this task) and perhaps
 * modify the settings here accordingly.  You will also need to set some parameters as
 * discussed in QuadrantSystemRDB.
 *
 * @author  Steven Bogaerts
 */
public class QuadrantTestClassRDB {

    /** Constructs the system, and tests it on a single problem. */
    public static void main(String[] args) {
        System.out.println("Hello World! ...... ");
        flush();

        long start, end, totalTime;

        // Construct the system.
        start = System.currentTimeMillis();

        QuadrantSystemRDB sys = new QuadrantSystemRDB();
        end = System.currentTimeMillis();
        totalTime = end - start;
        System.out.println("Total Time to construct system: " + totalTime + " in millisec");

        // Set the system to show a GUI of its status.
        sys.setGUIMode(true);

        /* Generate a problem to test the system on.  This problem generator is
        defined in the QuadrantSystem class. */
        start = System.currentTimeMillis();

        Problem p = sys.constructProblemGenerator().generateProblem();
        end = System.currentTimeMillis();
        totalTime = end - start;
        System.out.println("Total Time to generate a problem: " + totalTime + " in millisec");

        // Solve the problem.  The GUI will show what happens.
        start = System.currentTimeMillis();
        sys.solve(p);
        sys.close();
        end = System.currentTimeMillis();
        totalTime = end - start;
        System.out.println("Total Time to solve a problem: " + totalTime + " in millisec");
    }

    private static void flush() {
        String url = "jdbc:mysql://localhost:3306/hpdata";
        Connection con;
        Statement stmt;
        String query1 = "Delete from casebase";
        String query2 = "Delete from problem";
        String query3 = "Delete from solution";
        String query4 = "Delete from problemfeaturespec";
        String query5 = "Delete from solutionfeaturespec";
        String query6 = "Delete from inactivecontext";
        String query7 = "Delete from class";
        String query8 = "Delete from extradata";

        try {
            DriverManager.registerDriver(new com.mysql.jdbc.Driver());
           // DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
        } catch (Exception e) {
            System.out.println("Class Not Found Exception:");
            System.out.println(e.getMessage());
        }




        try {
            con = DriverManager.getConnection(url, QuadrantSystemRDB.USERNAME, QuadrantSystemRDB.PASSWORD);
            stmt = con.createStatement();
            System.out.println("Deleting Tables from Database...");
            System.out.println("casebase...");
            stmt.executeUpdate(query1);
            System.out.println("deleted\n");
            System.out.println("problem...");
            stmt.executeUpdate(query2);
            System.out.println("deleted\n");
            System.out.println("solution...");
            stmt.executeUpdate(query3);
            System.out.println("deleted\n");
            System.out.println("problemfeaturespec...");
            stmt.executeUpdate(query4);
            System.out.println("deleted\n");
            System.out.println("solutionfeaturespec...");
            stmt.executeUpdate(query5);
            System.out.println("deleted\n");
            System.out.println("inactivecontext...");
            stmt.executeUpdate(query6);
            System.out.println("deleted\n");
            System.out.println("class...");
            stmt.executeUpdate(query7);
            System.out.println("deleted\n");
            System.out.println("extradata...");
            stmt.executeUpdate(query8);
            System.out.println("deleted\n");
            stmt.close();
            con.close();
        } catch (Exception e) {
            System.out.println("SQLException:" + e.getMessage());
            e.printStackTrace();
        }
    }
}
  • 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-20T10:52:54+00:00Added an answer on May 20, 2026 at 10:52 am

    It looks like you have a background thread crashing (unexpected end-of-file when reading Base64 data), and the program is probably not handling this, but rather waiting (indefinitely) for the thread to return some result.

    Try to fix the input data, and then (if it is your program), add some error handling (i.e. catch the exception and notify the program that no data could be read).

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

Sidebar

Related Questions

I am working on a Java program and using Timer objects to run tasks
I usually run this program via a command line like so: java Program <TestClass.java
You launch a java program from a console (maybe using a .bat script). I
We have a Java program run as root on Unix, that therefore can read
I am writing this java program to find all the prime numbers up to
I have a java program which I run on a home server. I have
I'm writing this Java program that finds all the prime numbers between a given
I currently have a small Java program which I would like to run both
I have this java program which calculates the time that the person took to
I am trying to run a java program on my AIX server. I wrote

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.