This the file I am trying to store in the database. I want to get the title and comments stored. I do get it in, but it stores only the first line. Please help, not really good with databases.
title : The Descent Part 2 comment : badbaz83 : No it wasn't as good as the first one, but a hell of a lot better than I first feared. Worth a watch, but don't expect it to stand up to the first film. title : Supernatural comment : MissAyla : I loved this episode. :) I'm thoroughly enjoying the new style, just like the original episodes. title : Soccer Mom comment : chantellel93 : it's only 10 min so if u smoke 1 its worth the laugh 2/5. xx
Advertisement
Answer
You first need to split line
into Title
and Comment
and assign an id
. Try this (note it is case sensitive):
String s = line.toString(); Title = s.substring(8, s.indexOf("comment :")).trim(); Comment = s.substring(s.indexOf("comment :") + 10, s.length()).trim();
Then let us know where you get to.
I’m assuming you are trying to do this database insert (SQLFiddle ). To automatically assign an id you could set id as your auto_increment primary key (as per my example). You could then could make use of executeUpdate(String sql, int autoGeneratedKeys).
I’ll try and update my answer when you supply more details of the problem.