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.
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:
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);
}
}
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.
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?
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.
Re: Problem with entering data
So, for the example I gave above, would the database hold something like:
Code:
WORD
this
is
my
sample
text
it
has
two
lines
Re: Problem with entering data
So, for the example I gave above, would the database hold something like:
Code:
WORD
this
is
my
sample
text
it
has
two
lines
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).