Results 1 to 8 of 8
  1. #1
    Jey
    Jey is offline Member
    Join Date
    Aug 2011
    Location
    Czech Republic
    Posts
    12
    Rep Power
    0

    Default Problem with entering data

    Hi, i have this problem with entering data(mysql): ImageShack - Online Photo and Video Hosting

    My code is:
    try {
    int i = 0;
    char prvni_pismeno = 'a';
    char prvni_pismeno_equals = 'a';
    BufferedReader in = new BufferedReader(new FileReader("small.txt"));
    Connect.stmt.executeUpdate("CREATE TABLE tabulka(" + prvni_pismeno + " VARCHAR(100))");
    while ((str = in.readLine()) != null) {
    CharacterIterator it = new StringCharacterIterator(str);
    prvni_pismeno = it.first();

    if (prvni_pismeno == prvni_pismeno_equals) {
    Connect.stmt.executeUpdate("INSERT INTO tabulka(" + prvni_pismeno + ") VALUE ('" + str + "')");
    } else {
    Connect.stmt.executeUpdate("ALTER TABLE tabulka ADD " + prvni_pismeno + " VARCHAR(100)");
    Connect.stmt.executeUpdate("INSERT INTO tabulka(" + prvni_pismeno + ") VALUE ('" + str + "')");
    prvni_pismeno_equals = prvni_pismeno;
    }
    }
    } catch (IOException ex) {
    Logger.getLogger(Nacteni_database.class.getName()) .log(Level.SEVERE, null, ex);
    }
    }


    How can I repair null in row? Thanks very much for answer.
    Last edited by Jey; 10-10-2011 at 07:58 AM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,820
    Rep Power
    19

    Default Re: Problem with entering data

    Can you explain what you're doing?
    Few people will click through to a hosting site to see what your problem is.

    Also, when posting code please use code tags.
    Like this:
    Java Code:
    try {
                int i = 0;
                char prvni_pismeno = 'a';
                char prvni_pismeno_equals = 'a';
                BufferedReader in = new BufferedReader(new FileReader("small.txt"));
                Connect.stmt.executeUpdate("CREATE TABLE tabulka(" + prvni_pismeno + " VARCHAR(100))");
                while ((str = in.readLine()) != null) {
                    CharacterIterator it = new StringCharacterIterator(str);
                    prvni_pismeno = it.first();
    
                    if (prvni_pismeno == prvni_pismeno_equals) {
                        Connect.stmt.executeUpdate("INSERT INTO tabulka(" + prvni_pismeno + ") VALUE ('" + str + "')");
                    } else {
                        Connect.stmt.executeUpdate("ALTER TABLE tabulka ADD " + prvni_pismeno + " VARCHAR(100)");
                        Connect.stmt.executeUpdate("INSERT INTO tabulka(" + prvni_pismeno + ") VALUE ('" + str + "')");
                        prvni_pismeno_equals = prvni_pismeno;
                    }
                }
            } catch (IOException ex) {
                Logger.getLogger(Nacteni_database.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

  3. #3
    Jey
    Jey is offline Member
    Join Date
    Aug 2011
    Location
    Czech Republic
    Posts
    12
    Rep Power
    0

    Default Re: Problem with entering data

    Ok, so ... I want make mysql database with words (dictionary). And in Java i want make T9 (like in mobil phone).
    And now to my problem. I need words in one row.
    But with every cycle i have new row. Column (b,c...) will creating after entering all words begin for example 'a'.

    PS: Sorry for my english.
    Last edited by Jey; 10-10-2011 at 10:57 AM.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,820
    Rep Power
    19

    Default Re: Problem with entering data

    Your English is better than my Czech...:)

    Say small.txt looked like:
    This is my sample text.
    It has two lines.

    What would you expect the database to hold?

  5. #5
    Jey
    Jey is offline Member
    Join Date
    Aug 2011
    Location
    Czech Republic
    Posts
    12
    Rep Power
    0

    Default Re: Problem with entering data

    I want to use the mysql table to search for words (cca 800k words) and then write the word in the program (Java).
    File small.txt is only a few words to illustrate. File content is in image.
    Last edited by Jey; 10-10-2011 at 12:42 PM.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,820
    Rep Power
    19

    Default Re: Problem with entering data

    So, for the example I gave above, would the database hold something like:
    Java Code:
    WORD
    this
    is
    my
    sample
    text
    it
    has
    two
    lines

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,820
    Rep Power
    19

    Default Re: Problem with entering data

    So, for the example I gave above, would the database hold something like:
    Java Code:
    WORD
    this
    is
    my
    sample
    text
    it
    has
    two
    lines

  8. #8
    Jey
    Jey is offline Member
    Join Date
    Aug 2011
    Location
    Czech Republic
    Posts
    12
    Rep Power
    0

    Default Re: Problem with entering data

    I must have word order (A-Z) ... otherwise it does not work .... there will be duplicate (if words have same first letter).

Similar Threads

  1. Entering a number/name and getting a response
    By coding in forum Advanced Java
    Replies: 3
    Last Post: 02-01-2011, 02:15 PM
  2. Getting problem inserting data in data base
    By anupama in forum New To Java
    Replies: 4
    Last Post: 12-15-2010, 10:03 PM
  3. Replies: 1
    Last Post: 03-19-2009, 07:38 AM
  4. Entering a space as argument
    By Arne Bjarne in forum Eclipse
    Replies: 1
    Last Post: 03-02-2009, 12:43 PM
  5. How to stop entering Data
    By adeeb in forum AWT / Swing
    Replies: 1
    Last Post: 06-07-2008, 02:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •