Parsing textfile and creating sql command
Hi, people!
I need to parse values from textfile lines, and make sql for inserting that values into appropriate table. Each line has a form that looks like this one:
IdNum=xxxx;Name=抶x...x?Address=抶x...x?[LocalNum=xxxx;]Type=抶?
where IdNum, Name, Address, LocalNum and Type are name of columns, xxx are values and value in [ ] is optional columnname=value (columnname can have null values).
How can I do that? I cannot find any example that would help me.
[486 byte] By [
dalibora] at [2007-11-26 15:52:21]

OK, I managed to parse names of colums and values. Here is the code:
import java.util.*;
public class Strtok {
public static void main(String [] args) {
String str = "IdNum=xxxx;Name=抶x...x?Address=抶x...x?LocalNum=xxxx;Type=抶?";
StringTokenizer token = new StringTokenizer(str , "= ;");
while (token.hasMoreElements())
System.out.println(token.nextElement());
}
}
and output:
IdNum
xxxx
Name
抶x...x?Address
抶x...x?LocalNum
xxxx
Type
抶?
Now, how can I pass that values into insert query
INSERT INTO TableNAme (IDNum, Name, Address, LocalNum, Type)
VALUES (xxxx, 'xx...x', 'xx...x', xxxx,'x' );
?
Ahhhhh! Cross posted.
http://forum.java.sun.com/thread.jspa?threadID=5127555&tstart=0
Please do not crosspost (post your questions in more than one forum at the same time). Thanks
PS answer to question asked in reply 4 in this thread is answered by me in other thread.