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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:40:56+00:00 2026-05-25T11:40:56+00:00

I am trying to insert into mysql database dynamically. But I always see only

  • 0

I am trying to insert into mysql database dynamically. But I always see only current record in the database.. It is not appending into the particular column one after one another.. it just replace the previous entry made… I have to do some sort of commit after each data is added into the database? I think it performs auto commit automatically??

if (m.find() && thirdentry.startsWith("LO")) {
    Connection conn = null;
        Statement s = null;
        PreparedStatement ps = null;

        try
        {

        conn = DriverManager.getConnection
        ("jdbc:mysql://localhost/?user=root&password=admin"); 
        s=conn.createStatement();

        s.executeUpdate("CREATE DATABASE IF NOT EXISTS crawler");
        s.executeUpdate("USE crawler");

        s.executeUpdate ("DROP TABLE IF EXISTS crawl");

        s.executeUpdate (
        "CREATE TABLE crawl ("
        + "id INT UNSIGNED NOT NULL AUTO_INCREMENT,"
        + "PRIMARY KEY (id),"
        + "url VARCHAR(125), timestamp DATETIME, response TEXT, chksum TEXT)");


        java.util.Date date= new java.util.Date();

    //I always see only the current record.. not the full record
        ps = conn.prepareStatement (
        "INSERT INTO crawl (url, timestamp, response, chksum) VALUES(?,?,?,?)");
        ps.setString (1, url1.toString());
        ps.setString (2, new Timestamp(date.getTime()).toString());
        ps.setString (3, status);
        ps.setString (4, hash);
        int count = ps.executeUpdate ();
        s.close();
        ps.close ();

        System.out.println (count + " rows were inserted");
    }
 catch (Exception e)
   {
      System.err.println ("Cannot connect to database server" +e.getMessage());
     }
       finally
       {
     if (conn != null)
            {
                try
           {
               conn.close ();
                System.out.println ("Database connection terminated");
                                                        }
                   catch (Exception e) { /* ignore close errors */ }
                                                    }
                                                }
  • 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-25T11:40:57+00:00Added an answer on May 25, 2026 at 11:40 am

    You’re dropping the table and re-creating it every time you run the app. Create it once outside of the app, and let the app update it.

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

Sidebar

Related Questions

I'm trying to insert values from my asp.net application into my MySQL database. On
I am trying to insert a very long text string into a MySQL Blob
I received a MySQL data dump and am trying to insert the data into
I was trying to insert new data into an existing XML file, but it's
I'm trying to insert some import lines into a python source file, but i
Ok, when trying to insert into the database I'm getting this error You have
Hey guys, im trying to insert some checkboxes into a database and im pretty
I am trying to INSERT INTO a table using the input from another table.
I've got a DateTime? that I'm trying to insert into a field using a
I'm trying to insert a column into an existing DataSet using C#. As an

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.