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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:05:04+00:00 2026-06-10T11:05:04+00:00

So I want to send a user to a mysql database with the columns:

  • 0

So I want to send a user to a mysql database with the columns: user, skill, time
Now, I want it to be able to add more then one row for the same user but having different time and etc, how would I do this? Here’s my code for sending it to the database:

   public static boolean recentActivity(Player paramPlayer){
    try {
        Statement statement = con.createStatement();
        ResultSet group = statement.executeQuery("SELECT * FROM recentactivity WHERE user = '"+ paramPlayer.getDisplayName() + "'");
        if (!group.next() && !paramPlayer.levelTime.equals(""))
                statement.execute("INSERT INTO `recentactivity`(`user`, `skill`, `time`) VALUES('"+ paramPlayer.getDisplayName() +"', '"+ paramPlayer.levelledSkill +"', '"+ paramPlayer.levelTime +"')");
    } catch (Exception localException) {
        return false;
    }
    return true;

}
Then I have this to use it:

    java.util.Date dt = new java.util.Date();
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
    String currentTime = sdf.format(dt);
    player.levelledSkill = skill;
    player.levelTime = ""+currentTime+"";
    Hiscores.recentActivity(player);

Any help with this?

Schema:

CREATE TABLE IF NOT EXISTS recentactivity ( 
    user varchar(255) NOT NULL
    , skill int(11) NOT NULL
    , time varchar(255) NOT NULL
    , PRIMARY KEY (user) 
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  • 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-10T11:05:06+00:00Added an answer on June 10, 2026 at 11:05 am

    IIUC you want to add more than one row for the same user.

    However, you have two places in you code that are preventing you from doing this.

    The first piece is in java :

    if (!group.next()

    It searches if there is already a row for that user, and executes the INSERT only if there is none.

    However, that code is there to prevent an SQL exception to occur. In your SQL schema, user is the primary key of the table, so you cannot insert two rows with the same user.

    You should change these two places (remove the primary key, remove the !group.next), but first check if the rest of the application will still work with multiple rows pertaining to the same user, cause it seems like it has been designed to prevent that situation more than to allow it.

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

Sidebar

Related Questions

I want that user/attacker to encrypt the data and send to server. Now I
I want to send some info back to my database when a user prints
I want to send a textarea's data when user presses shift + enter ,
i want to send an email to user after he sign-up with code.for ex
I want to send ViewData.model to Special action with the last user data entry.
I have a page (A) and a user control and I want to send
I want to implement in my application the option to send the current user
When a user presses the SEND(return) button I want the keyboard to retract and
In my application i want send a email to one account.in one button click
I have mysql database i.e. central database and i use ASP .net. I want

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.