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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:29:53+00:00 2026-06-10T03:29:53+00:00

I’m concerned about my Java client directly connecting to the MySQL server due to

  • 0

I’m concerned about my Java client directly connecting to the MySQL server due to all of the issues that could occur, and the security risks I believe it could pose. Such as someone being able to decompile the file and get the login details for the database. As beautiful as it would be, I’m too scared to take that risk. I’ve written a PHP script to echo data that the client can interpret. The PHP script is what connects to the MySQL.

It’s rather simple: Java->PHP->MySQL

I’m going to provide screenshots of the MySQL structure, so you may better understand when trying to visualize this.
enter image description here
http://i.imgur.com/5EViC.png
enter image description here
enter image description here

id: possibly tid/sid

tid: teacher id, used to link to the teacher

sid: student id, used to link to the student

gid: grade id

aid: assignment id

gp: gained points

pp: possible points

Grading rows are for each assignment per student. So for example if a teacher had 30 students assigned to one assignment, there would be 30 rows in the grading tab and one in the assignments. Duplicate assignment names are NOT allowed.

When the client is requesting the data, I just use a buffered reader & URL to download the string. This is the example output of when the client receives the assignment names.

Test Assignment;Secondary Test Assignment;

This is what it looks like to the client once the column names are downloaded:
enter image description here

As you can see the first two columns are there by default, the last two are assignment names.

I want each row in the table to be a student. However, here is where my trouble comes in. I’m trying to receive the proper data from grading. I don’t know how I’m going to do this. I have about 3 months experience with Java, so you could definitely call me a newbie.

Here is my idea, but I didn’t think it was so great of an idea:
Search through all of the column names and insert the value into the proper column in that row where assignment name matches.

I didn’t know how difficult that would be. I’m guessing the nice people who developed swing built something in for that, but I can’t find any resources.

Does anyone have any recommendations on what to do in this situation? I feel lost.

  • 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-10T03:29:54+00:00Added an answer on June 10, 2026 at 3:29 am

    Let’s start with the Java client. Here is some code that reads from a php page and that creates a JTable out of it. (actually it’s reading from a String for simplicity but you can easily change the code to match your real case, see the comment in the code).

    public static void main(String[] args) throws Exception {
        String receivedFromPHP = "Student ID;Student Name;Test Assignment;Secondary Test Assignment;\n"
                + "1;Luc;Test assignment 1;Secondary Test assignment 1;\n"
                + "2;Vador;Test assignment 2;Secondary Test assignment 2;";
    
        BufferedReader br = new BufferedReader(new StringReader(receivedFromPHP));
        // For real: br = new BufferedReader(new InputStreamReader(new URL("http://localhost/yourPhpPage.php").openStream()));
    
        DefaultTableModel dtm = new DefaultTableModel();
    
        String line;
        boolean headersReceived = false;
        while ((line = br.readLine()) != null) {
            String[] columns = line.split(";");
            if (!headersReceived) {
    
                dtm.setColumnIdentifiers(columns);
                headersReceived = true;
            } else {
                dtm.addRow(columns);
            }
        }
    
        JTable table = new JTable(dtm);
        JFrame f = new JFrame();
        f.add(new JScrollPane(table));
        f.pack();
        f.setLocationRelativeTo(null);
        f.setVisible(true);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    

    Nothing really difficult until now. The real thing is to write the php page with the proper query. Obviously, you know better what you want your page to output but I guess your are going for something like this:

    <?php
    
    $mysqli = new mysqli("localhost", "my_user", "my_password", "pinkfluf_dvonx");
    
    /* check connection */
    if ($mysqli->connect_errno) {
        printf("Connect failed: %s\n", $mysqli->connect_error);
        exit();
    }
    
    
    /* Select queries return a resultset */
    if ($result = $mysqli->query("SELECT Name FROM City LIMIT 10")) {
        printf("Select returned %d rows.\n", $result->num_rows);
    
        /* free result set */
        $result->close();
    }
    
    /* If we have to retrieve large amount of data we use MYSQLI_USE_RESULT */
    if ($result = $mysqli->query('SELECT u.id AS "Student ID", u.username AS "Student Name", ... FROM members u, grading g, assignments a WHERE ...')) {
    
        while($row = $result->fetch_array(MYSQLI_NUM)) {
            for ($i=0; $i<sizeof($row); $i++) {
                echo $row[$i] . ";";
            }
            echo "\n";
        }
    
        $result->close();
    }
    
    $mysqli->close();
    ?>
    

    Of course, the code I give here is very approximative (given the information I could extract from your question) so it’s certain that you’ll need to adapt the code to make it work as you’d like to but I hope it can help you getting started (keep going :)).

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I have a text area in my form which accepts all possible characters from
I know there's a lot of other questions out there that deal with this

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.