Results 1 to 8 of 8
Thread: Problem with entering data
- 10-10-2011, 07:42 AM #1
Member
- Join Date
- Aug 2011
- Location
- Czech Republic
- Posts
- 12
- Rep Power
- 0
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.
- 10-10-2011, 10:46 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
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); } }
- 10-10-2011, 10:52 AM #3
Member
- Join Date
- Aug 2011
- Location
- Czech Republic
- Posts
- 12
- Rep Power
- 0
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.
- 10-10-2011, 11:04 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
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?
- 10-10-2011, 12:20 PM #5
Member
- Join Date
- Aug 2011
- Location
- Czech Republic
- Posts
- 12
- Rep Power
- 0
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.
- 10-10-2011, 02:04 PM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
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
- 10-10-2011, 02:04 PM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
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
- 10-10-2011, 02:42 PM #8
Member
- Join Date
- Aug 2011
- Location
- Czech Republic
- Posts
- 12
- Rep Power
- 0
Similar Threads
-
Entering a number/name and getting a response
By coding in forum Advanced JavaReplies: 3Last Post: 02-01-2011, 02:15 PM -
Getting problem inserting data in data base
By anupama in forum New To JavaReplies: 4Last Post: 12-15-2010, 10:03 PM -
java error encountered while entering data in the database.security.accessControlexce
By shallz in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 03-19-2009, 07:38 AM -
Entering a space as argument
By Arne Bjarne in forum EclipseReplies: 1Last Post: 03-02-2009, 12:43 PM -
How to stop entering Data
By adeeb in forum AWT / SwingReplies: 1Last Post: 06-07-2008, 02:58 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks