我有Web服務,並且我正在從webservice獲取數據並將該數據存儲到數據庫中,但是我發出異常並且檢查了我的數據庫在設備上成功創建我正在關閉正常我的數據庫打開成功 我認爲這是我的web服務數據中的特殊字符問題,我在我的web服務中有一些故事,並conatin一些特殊字符...,當我嘗試將它們插入我的數據庫他們給了SQL邏輯錯誤 嘗試conn =(StreamConnection)Connector.open(「http://tandonindia.com/story_new_xml?user=500」+「; deviceside = true」/ +「; interface = wifi」 /);處理黑莓中的特殊字符並將其存儲到數據庫中
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setIgnoringElementContentWhitespace(true);
docBuilderFactory.setCoalescing(true);
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
docBuilder.isValidating();
is = conn.openInputStream();
doc = docBuilder.parse(is);
doc.getDocumentElement().normalize();
System.out.println ("ROOT ELEMENT OF DOCUMENT IS= " + doc.getDocumentElement().getNodeName());
//add(new LabelField(""+ doc.getDocumentElement().getNodeName()));
NodeList nodeList = doc.getElementsByTagName("item");
for (int i = 0; i < nodeList.getLength(); i++){
//System.out.println(""+nodeList.getLength());
Node node = nodeList.item(i);
if(node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) node;
NodeList nodelist = element.getElementsByTagName("Week");
Element element1 = (Element) nodelist.item(0);
NodeList fstNm = element1.getChildNodes();
System.out.print("Week-- " + (fstNm.item(0)).getNodeValue().toString());
Element element2 = (Element) node;
NodeList nodelist1 = element2.getElementsByTagName("Year");
Element element3 = (Element) nodelist1.item(0);
NodeList fstNm1 = element3.getChildNodes();
System.out.println("\nYear-- "+(fstNm1.item(0)).getNodeValue().toString());
//For retriving text from node notification
Element element4 = (Element) node;
NodeList nodelist2 = element4.getElementsByTagName("subject");
Element element5 = (Element) nodelist2.item(0);
NodeList fstNm2 = element5.getChildNodes();
System.out.println("subject--" + (fstNm2.item(0)).getNodeValue().toString());
//For retriving text from node Link
Element element15 = (Element) node;
NodeList nodelist21 = element15.getElementsByTagName("storypath");
Element element51 = (Element) nodelist21.item(0);
NodeList fstNm22 = element51.getChildNodes();
System.out.println("storypath--" + (fstNm22.item(0)).getNodeValue().toString());
try {
db2 = DatabaseFactory.open(str);
db2.beginTransaction();
Statement statmnt2 = db2.createStatement("INSERT into tbstory(Week,Year,subject,storypath) VALUES("+"'"+(fstNm.item(0)).getNodeValue().toString()+"','"+(fstNm1.item(0)).getNodeValue().toString()+"','"+(fstNm2.item(0)).getNodeValue().toString()+"','"+(fstNm22.item(0)).getNodeValue().toString()+"')");
System.out.println("INSERTING STORYIESSSSSSSSSSSSSSSSS");
statmnt2.prepare();
statmnt2.execute();
statmnt2.close();
db2.commitTransaction();
db2.close();
} catch (Exception e) {
// TODO Auto-generated catch block
db2.close();
System.out.println("1111222333"+e.toString());
e.printStackTrace();
}
}
}
System.out.println("----------------");
}catch(Exception e){
System.out.println("error 1"+e.getMessage());
}
和我得到下面的錯誤是 net.rim.device.api.database.DatabaseException:INSERT INTO tbstory(星期,年,主題,故事[0.0]路徑)VALUES('25' ,」 2013' ,‘獎勵蔬菜!’,'巴巴告訴這個故事給學生在科代卡那。
now this time i have very less content , again i got the error on INSERT query and how can i find that which character is giving me error, i'll post my exception while adding a small string in my Database.. can u tell me according to you which character is giving error or how can i figure out which character is giving me error
net.rim.device.api.database.DatabaseException: INSERT into tbstory(storypath) VALUES('O[0.0] ne day, the Pandit came excitedly and told Rabidas, a cobbler, "My friend Today the queen is coming [0.0] to have the holy bath. I have been called to do the rit[0.0] uals; for today is a very special day, whoever has a dip in mother Ganga could emerge all pure. Do C[0.0] ome Don't miss this opportunity" Rabidas shook his head and said "Man changa to katooti me Ganga", p[0.0] ointing to his leather bag, (if mind is pure Ganga will[0.0] be in my leather bag).
[0.0]
[0.0]
[0.0]
[0.0] Angrily the Pandit went away muttering, "When will this fool understand the truth and try to earn Go[0.0] d's Grace?" His life will be spent in the company of this disgusting leather only'.
[0.0]
[0.0]
[0.0]
[0.0] In the evening the Pandit came panting, "Rabi, What a miracle occurred today Ganga Mayya Blessed ou[0.0] r queen with a golden bangle and told her she will get the second one when a person as pure and as d[0.0] evoted as she come to there to dip in the holy river. T[0.0] omorrow the whole city of Kashi will come and see who that lucky Blessed person is".
[0.0]
[0.0]
[0.0]
[0.0] Rabi said "My dear friend It must be you only; for who can be more purer and devoted than you who ta[0.0] ke hundreds of people for holy bath every day?"
[0.0]
[0.0]
[0.0]
[0.0] Pleased and puffed up with pride the Pandit said, "I know it must be me only. Tomorrow I will be the[0.0] first person to take the holy dip".
[0.0]
[0.0]
[0.0]
[0.0] Next day, the Pundit came late in the evening with an air of dejection over him. Rabi asked "So, my [0.0] friend did you get the second bangle?
[0.0]
[0.0]
[0.0]
[0.0] Rabi closed his eyes and silently prayed "Oh mother, why don't you save this poor Pundit from this d[0.0] ilemma? I know you are everywhere and manifest anything at any time. Then he put his hand into his [0.0] leather bag and Lo Wonder of wonders A shinning gold b[0.0] angle emerged
[0.0]
[0.0]
[0.0]
[0.0] The Pandit was spellbound at this great miracle. He bowed down to the cobbler in all humility.
[0.0]
[0.0]
[0.0]
[0.0] "My dear, you have opened my eyes. All work is worship of God; Inner Purity is greater than Outer Pu[0.0] rity.'): SQL logic error or missing database