Don't Insert datas into table [message #216946] |
Wed, 31 January 2007 00:29 |
izy25
Messages: 1 Registered: January 2007
|
Junior Member |
|
|
I'd like to INSERT datas from XML file into table and I don't know what is wrong. Please help! Thanks in advance
try {
logger.info("-----------------------------------------------");
Class.forName(is_dbmsDriverDest);
logger.info("Connecting to " + is_dbmsURLDest);
lconnPhonebookError = DriverManager.getConnection(is_dbmsURLDest, is_dbmsUserDest, is_dbmsPassDest);
lstmPhonebookError = lconnPhonebookError.createStatement();
FileInputStream fileInputStream = new FileInputStream(is_XMLFile);
XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream);
ls_sql =
" INSERT INTO t_phonebook_error (" +
" phone_book_id," +
" description)" +
" VALUES (?,?)";
lprepstmPhonebookError = lconnPhonebookError.prepareStatement(ls_sql);
while (xmlStreamReader.hasNext()) {
li_count++;
int eventCode = xmlStreamReader.next();
switch (eventCode) {
case XMLStreamConstants.START_ELEMENT :
if ((xmlStreamReader.getLocalName()=="Error") && (xmlStreamReader.getAttributeCount()>0))
ls_description = xmlStreamReader.getAttributeValue(0);
else if ((xmlStreamReader.getLocalName()=="ZAPIS") && (xmlStreamReader.getAttributeCount()>0))
for (int i=0; i < xmlStreamReader.getAttributeCount(); i++)
{if (xmlStreamReader.getAttributeLocalName(i).equals("ID"))
li_phonebook_id = Integer.parseInt(xmlStreamReader.getAttributeValue(i));
}
break;
case XMLStreamConstants.END_ELEMENT :
lprepstmPhonebookError.setInt (1, li_phonebook_id);
lprepstmPhonebookError.setString (2, ls_description);
break;
}
if (li_count > 0)
logger.info("Transfered " + li_count + " PhonebookError(s)");
logger.info("Finished");
xmlStreamReader.close();
}
lprepstmPhonebookError.executeUpdate(ls_sql);
lprepstmPhonebookError.close();
lprepstmPhonebookError = null;
}
[Updated on: Wed, 31 January 2007 04:38] Report message to a moderator
|
|
|