How to store xml document in d/b using jsp
hai,
Iam doing one web application in JSP, i have a requirement to store the xml document in database. We have to use some xml parsers, so can anyone please give me the related code in JSP.
regards,
Praveen Vinnakota.
If you have to store the Whole XML Document then I don't think you need to mess with XML Parsers. I mean simply the XML File in the Database Field where it has to stored
Bye for now
CSJakharia
Similar Messages
-
How to store xml data into file in xml format through java program?
HI Friends,
Please let me know
How to store xml data into file in xml format through java program?
thanks......
can discuss further at messenger.....
Avanish Kumar Singh
Software Engineer,
Samsung India Development Center,
Bangalore--560001.
[email protected]Hi i need to write the data from an XML file to a Microsoft SQL SErver database!
i got a piece of code from the net which allows me to parse th file:
import java.io.IOException;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import org.apache.xerces.parsers.SAXParser;
import java.lang.*;
public class MySaxParser extends DefaultHandler
private static int INDENT = 4;
private static String attList = "";
public static void main(String[] argv)
if (argv.length != 1)
System.out.println("Usage: java MySaxParser [URI]");
System.exit(0);
String uri = argv[0];
try
XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
MySaxParser MySaxParserInstance = new MySaxParser();
parser.setContentHandler(MySaxParserInstance);
parser.parse(uri);
catch(IOException ioe)
ioe.printStackTrace();
catch(SAXException saxe)
saxe.printStackTrace();
private int idx = 0;
public void characters(char[] ch, int start, int length)
throws SAXException
String s = new String(ch, start, length);
if (ch[0] == '\n')
return;
System.out.println(getIndent() + " Value: " + s);
public void endDocument() throws SAXException
idx -= INDENT;
public void endElement(String uri, String localName, String qName) throws SAXException
if (!attList.equals(""))
System.out.println(getIndent() + " Attributes: " + attList);
attList = "";
System.out.println(getIndent() + "end document");
idx -= INDENT;
public void startDocument() throws SAXException
idx += INDENT;
public void startElement(String uri,
String localName,
String qName,
Attributes attributes) throws SAXException
idx += INDENT;
System.out.println('\n' + getIndent() + "start element: " + localName);
if (localName.compareTo("Machine") == 0)
System.out.println("YES");
if (attributes.getLength() > 0)
idx += INDENT;
for (int i = 0; i < attributes.getLength(); i++)
attList = attList + attributes.getLocalName(i) + " = " + attributes.getValue(i);
if (i < (attributes.getLength() - 1))
attList = attList + ", ";
idx-= INDENT;
private String getIndent()
StringBuffer sb = new StringBuffer();
for (int i = 0; i < idx; i++)
sb.append(" ");
return sb.toString();
}// END PRGM
Now , am not a very good Java DEv. and i need to find a soln. to this prob within 1 week.
The next step is to write the data to the DB.
Am sending an example of my file:
<Start>
<Machine>
<Hostname> IPCServer </Hostname>
<HostID> 80c04499 </HostID>
<MachineType> sun4u [ID 466748 kern.info] Sun Ultra 5/10 UPA/PCI (UltraSPARC-IIi 360MHz) </MachineType>
<CPU> UltraSPARC-IIi at 360 MHz </CPU>
<Memory> RAM : 512 MB </Memory>
<HostAdapter>
<HA> kern.info] </HA>
</HostAdapter>
<Harddisks>
<HD>
<HD1> c0t0d0 ctrl kern.info] target 0 lun 0 </HD1>
<HD2> ST38420A 8.2 GB </HD2>
</HD>
</Harddisks>
<GraphicCard> m64B : PCI PGX 8-bit +Accel. </GraphicCard>
<NetworkType> hme0 : Fast-Ethernet </NetworkType>
<EthernetAddress> 09:00:30:C1:34:90 </EthernetAddress>
<IPAddress> 149.51.23.140 </IPAddress>
</Machine>
</Start>
Note that i can have more than 1 machines (meaning that i have to loop thru the file to be able to write to the DB)
Cal u tellme what to do!
Even better- do u have a piece of code that will help me understand and implement the database writing portion?
I badly need help here.
THANX -
How can I access xml document from javascript whithin a JSP page
how can I access xml document from javascript whithin a JSP page?
I have a JSP that receives an XML document from a JavaBean, so I can access it within the entire JSP, but I need to access it from the javascript inside the JSP... and I have no idea how i can do this.
Thanks in advance!The solution would only work on MS IE browsers, as other browsers do not support an XML DOM.
It can be done, but you would be stuck with using the Microsoft broswer. If that is acceptable, I have some example code, and a book recommendation. -
Got error message when store XML documents into XML DB repository, via WebD
Hi experts,
I am in I am in Oracle Enterprise Manager 11g 11.2.0.1.0.
SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 22 11:40:23 2011
I got error message when store XML documents into XML DB repository, via WebDAV.
I have successfully registered 5 related schemas and generated 1 table.
I have inserted 40 .xml files into this auto generated table.
using these data I created relational view successfully.
but since I couldn't store XML documents into XML DB repository, via WebDAV
when I query using below code:
SELECT rv.res.getClobVal()
FROM resource_view rv
WHERE rv.any_path = '/home/DEV/messages/4fe1-865d-da0db9212f34.xml';
I got nothing.
My ftp code is listed below:
ftp> open localhost 2100
Connected to I0025B368E2F9.
220- C0025B368E2F9
Unauthorised use of this FTP server is prohibited and may be subject to civil and criminal prosecution.
220 I0025B368E2F9 FTP Server (Oracle XML DB/Oracle Database) ready.
User (I0025B368E2F9:(none)): fda_xml
331 pass required for FDA_XML
Password:
230 FDA_XML logged in
ftp> cd /home/DEV/message
250 CWD Command successful
ftp> pwd
257 "/home/DEV/message" is current directory.
ftp> ls -la
200 PORT Command successful
150 ASCII Data Connection
drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 .
drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 ..
226 ASCII Transfer Complete
ftp: 115 bytes received in 0.00Seconds 115000.00Kbytes/sec.
250 SET_CHARSET Command Successful
ftp> put C:\ED\SPL\E_Reon_Data\loaded\4fe1-865d-da0db9212f34.xml
200 PORT Command successful
150 ASCII Data Connection
550- Error Response
ORA-00600: internal error code, arguments: [qmxConvUnkType], [], [], [], [], [], [], [], [], [], [], []
550 End Error Response
ftp: 3394 bytes sent in 0.00Seconds 3394000.00Kbytes/sec.
I have tried all suggestion from another thread such as:
alter system set events ='31150 trace name context forever, level 0x4000'
SQL> alter system set shared_servers = 1;
but failed.
is there anyone can help?
Thanks.
Edited by: Cow on Mar 29, 2011 12:58 AMHi experts,
I am in I am in Oracle Enterprise Manager 11g 11.2.0.1.0.
SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 22 11:40:23 2011
I got error message when store XML documents into XML DB repository, via WebDAV.
I have successfully registered 5 related schemas and generated 1 table.
I have inserted 40 .xml files into this auto generated table.
using these data I created relational view successfully.
but since I couldn't store XML documents into XML DB repository, via WebDAV
when I query using below code:
SELECT rv.res.getClobVal()
FROM resource_view rv
WHERE rv.any_path = '/home/DEV/messages/4fe1-865d-da0db9212f34.xml';
I got nothing.
My ftp code is listed below:
ftp> open localhost 2100
Connected to I0025B368E2F9.
220- C0025B368E2F9
Unauthorised use of this FTP server is prohibited and may be subject to civil and criminal prosecution.
220 I0025B368E2F9 FTP Server (Oracle XML DB/Oracle Database) ready.
User (I0025B368E2F9:(none)): fda_xml
331 pass required for FDA_XML
Password:
230 FDA_XML logged in
ftp> cd /home/DEV/message
250 CWD Command successful
ftp> pwd
257 "/home/DEV/message" is current directory.
ftp> ls -la
200 PORT Command successful
150 ASCII Data Connection
drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 .
drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 ..
226 ASCII Transfer Complete
ftp: 115 bytes received in 0.00Seconds 115000.00Kbytes/sec.
250 SET_CHARSET Command Successful
ftp> put C:\ED\SPL\E_Reon_Data\loaded\4fe1-865d-da0db9212f34.xml
200 PORT Command successful
150 ASCII Data Connection
550- Error Response
ORA-00600: internal error code, arguments: [qmxConvUnkType], [], [], [], [], [], [], [], [], [], [], []
550 End Error Response
ftp: 3394 bytes sent in 0.00Seconds 3394000.00Kbytes/sec.
I have tried all suggestion from another thread such as:
alter system set events ='31150 trace name context forever, level 0x4000'
SQL> alter system set shared_servers = 1;
but failed.
is there anyone can help?
Thanks.
Edited by: Cow on Mar 29, 2011 12:58 AM -
Trying to store XML documents in Oracle XML repository using Java
Hi,
I am trying to store XML documents in Oracle XML Repository using a Java program. i just need a functionality to be able to store XML files and retrieve them.
Can anybody PLEASE provide me some sample code.
Thanks in Advance
SashaDid you ever get any samples on doing this and if so could you pass it on to me.
Thanks -
How to publish XML document whose source is stored in clob column
I have to create simple application:
in one table are stored some information about XML documents (date of creation, etc.) and the document source itself in one (unfortunatelly clob type) column.
The point is to anable users finding document(s) and viewing it.
Using forms I can search and display information about documents. But I have no idea how to publish XML document whose source is stored in clob column.
I am using Oracle Portal 3.0 on NT.
Thanks in advance.Hi Sergio,
This link might be helpful:
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/apex31blob.htm
Also refer the BLOB Download Format Mask :
{message:id=9716335}
Here I have given the format mask for APEX 4.0, which will slightly differ for 3.2.1 and proposed changes
in the format mask are:
1) Format Mask: DOWNLOAD
2) Content Disposition: Inline
This will be achieved with it:
>
But now, my user would like to know if it´s possible that APEX application can OPEN some of these files stored on this BLOB column WITHOUT download it.
My user would like to see a hiperlink (or button) that, if pressed/acessed, can open a new page (or a page inside application) with the document. He doesn´t need to edit this oppened file. He only wants to see it.
>
Hope it helps!
Regards,
Kiran -
Import XML document in MS Access through Jsp
Hai,
Can any one please tell how to import/store XML document into database, I have tried a lot, but failed to get the result. So please can anyone send me the related code for storing the XML document into database.
Thanking you in advance,
Praveen Vinnakota.You can store the XML Document as a String Data In the database and thus no need to use XML Parsers
Bye for now
CSJakharia -
Please tell how to store jpeg images in SQL Server using NI Database Connectivity Toolset.
http://www.w3schools.com/sql/sql_datatypes.asp
You setup a field as BLOB and store the binary of the picture there. Depending on the database it can be called differently as you can see in the link, in SQL server there's even a Image datatype.
/Y
LabVIEW 8.2 - 2014
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
G# - Free award winning reference based OOP for LV -
How to send XML file to https server using POST
Hi, I am having an requirement, that I have to connect to https server and I have to pass an input XML file as a response server will give me output XML file.
The certificate validation part is over, I am using FileInputStream to read the XML file and attaching this to connection.getOutputStream(); but server is throwing me DTD does n't match.
Can any body tell me how to send XML file, I have to use any DOM parser to send the XML file, suggest me and give me sample code.
Thanks,Can anybody give me the solution
-
How to read XML message present in Table using PL/SQL?
Hi,
How to read XML content present in Table using PL/SQL .And is it possible to parse the xml uisng xslt and insert xml output in same table again ?
Thanks!Late reply, but hopefully better late than never.
You can possibly do it all via a single SQL statement, such as {message:id=4232077}
XMLTable Syntax can be found at http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions228.htm#CIHGGHFB (for 10.2 users) else find your correct version at http://www.oracle.com/technology/documentation/index.html -
How to under complete document to configure prerequisite using fields both
Hi,
When I configure prerequisite under complete document for one substitution but fialed withe syntax error when I tried use the following prerequisite:
BKPF-BUKRS = 'XXXX' AND
BSEG-HKONT IN SET1
But I input this prerequisite under line item it is ok . I am wondering if there is no permit for BSEG table field under prerequisite under complete document. Pls give me some advice on how to under complete document to configure prerequisite using fields both in BKPF and BSEG. Thanks.Hi Mohan,
I did active it at call point3(complete document) but my question is when I configure prerequest I am confused that only BKPF data fields can be used in prerequest. Why field in BSEG can not be used in prerequisite? Once I input BSEG field in prerequisite there will be syntax error message shown up. -
I am very new to this JDeveloper & BPEl Process , please could some one help in ersolving my problem that is , how to upload a file in BPEL Console Using JSP in JDeveloper.
Hi,
ADF Faces provides you with the file upload component
http://download-uk.oracle.com/docs/html/B25947_01/web_complex006.htm#CEGCEDHF
http://download-uk.oracle.com/docs/html/B25947_01/appendixa007.htm#CHDEDCFA
This gives you a handle to the file content. However, uploading files through a service is different and I suggest to consult teh BPEL forum for this BPEL
Frank -
How to upload a file in BPEL Console Using JSP in JDeveloper, please help..
Please I am new to Jdeveloper and to BPEL Process of OASuite,I want to know , how to upload a file in BPEL process using JSP in Jdeveloper IDE.
The main aim is first we need to upload a file in JSP , it has to go to BPEL Process & it has to read the file & write the respective file in return to JSP through BPEL Process. Please I am in Urgent need of the Query , please help me ASAP.
Send to me response Please.....................................Hi,
I thin that you asked the same question before and I premember that I ointed you to the ADF BC developer guide and the SRDemo if your application uses JSF. For plain JSP - if you Google for: JSP and file upload then you find plenty of sources for JSP and Struts.
The remaining part is how to stiff the file into a BPEL service on the middle tier. For this I recommended to ask your question on the BPEL forum
BPEL
Note that the BPEL integration would be easier if it was done on the middle tier and not onthe client
Frank -
How 2 get the path of a file Using jsp
how 2 get the path of a file Using jsp
i have tried getPath...but i'm geting the error
The method getPath(String) is undefined for the type HttpServletRequest
any idea how 2 get the path of a fileYou need ServletContext#getRealPath().
API documentation: http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String) -
How to parse XML document returned by webservices
Hi,
I have a form (version 10.1.2.0) which has to display the credit card types using webservices. I created the webstub and jar file through jdeveloper and then after adding the jar files in the respective classpaths, I import it in the forms. I write the code in when-button-pressed and it gives the result in xml document like this:
<?xml version="1.0" encoding="UTF-8"?><WSAnswerTO><error>false</error><errorMessage></errorMessage><
results><CardTypeTO><carTypId>3</carTypId><type>AMERICAN
EXPRESS</type><numLength>15</numLength><cvvLength>4</cvvLength><comments>1 800-639-0002</comments></CardTypeTO><CardTypeTO><carTypId>4</carTypId><type>DISCOVER</type><numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-347-2683</comments></CardTypeTO><CardTypeTO><carTypId>1</carTypId><type>MASTERCARD</type><numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-633-7367</comments></CardTypeTO><CardTypeTO><carTypId>2</carTypId><type>VISA</type><numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-945-2000</comments></CardTypeTO></results></WSAnswerTO>
From the above xml document, I only need to display the type (such as AMERICAN EXPRESS, VISA, ETC) in my forms. Can somebody please tell me how to do it. Do I need to store the values in a table first and then retrieve it. Please advise. I have already read a otn document in xml parsing but I didnt understand anything from it.
Please help. Thanks in advance.Hello,
It probably exists a database package/function to parse this kind of stuff.
If you want to keep the process into the Forms, here is a PL/SQL package you can use:
CREATE OR REPLACE PACKAGE Pkg_Tools AS
-- Types --
-- table of strings --
TYPE TYP_TAB_CHAR IS TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER;
-- Methodes --
-- function that return all contents for a given XML tag --
FUNCTION Get_Xml_Tag
PC$XmlContent IN VARCHAR2, -- XML string
PC$Tag IN VARCHAR2, -- searched tag
PC$NewLine IN VARCHAR2 DEFAULT CHR(10) -- defaull NL character
RETURN TYP_TAB_CHAR ;
END Pkg_Tools;
CREATE OR REPLACE PACKAGE BODY Pkg_Tools
IS
-- fonction de retour du contenu d'une balise XML --
FUNCTION Get_Xml_Tag
PC$XmlContent IN VARCHAR2, -- contenu XML
PC$Tag IN VARCHAR2, -- tag recherche
PC$NewLine IN VARCHAR2 DEFAULT CHR(10) -- defaull NL character
RETURN TYP_TAB_CHAR
IS
TC$Table TYP_TAB_CHAR ;
LC$Ligne VARCHAR2(32000) ;
LC$Xml VARCHAR2(32000) ;
LN$INDEX PLS_INTEGER := 0 ;
LN$TagDeb PLS_INTEGER ;
LN$TagFin PLS_INTEGER ;
LN$TagLength PLS_INTEGER ;
LN$LigLength PLS_INTEGER ;
LN$Occur PLS_INTEGER := 1 ;
BEGIN
IF ( PC$XmlContent IS NOT NULL AND PC$Tag IS NOT NULL ) THEN
LC$Xml := REPLACE( PC$XmlContent, CHR(13), '' ) ;
LN$TagLength := LENGTH( PC$Tag ) ;
LOOP
LN$TagDeb := INSTR( LC$Xml, PC$Tag, 1, LN$Occur ) ;
LN$TagFin := INSTR( LC$Xml, '</' || SUBSTR(PC$Tag,2, 256), 1, LN$Occur ) ;
LN$LigLength := (LN$TagFin - ( LN$TagDeb + LN$TagLength ) ) ;
IF (LN$TagDeb > 0 AND LN$TagFin > 0 ) THEN
LN$Occur := LN$Occur + 1 ;
LC$Ligne := SUBSTR( LC$Xml, LN$TagDeb + LN$TagLength, LN$LigLength ) ;
LOOP
LN$INDEX := LN$INDEX + 1 ;
LN$TagDeb := INSTR( LC$Ligne, PC$NewLine ) ;
IF LN$TagDeb > 0 THEN
IF Trim( SUBSTR( LC$Ligne, 1, LN$TagDeb - 1 )) IS NOT NULL THEN
TC$Table(LN$INDEX) := SUBSTR( LC$Ligne, 1, LN$TagDeb - 1 ) ;
ELSE
LN$INDEX := LN$INDEX - 1 ;
END IF ;
LC$Ligne := SUBSTR( LC$Ligne, LN$Tagdeb + LENGTH( PC$NewLine ), 30000 ) ;
ELSE
IF Trim(LC$Ligne) IS NOT NULL THEN
TC$Table(LN$INDEX) := LC$Ligne ;
END IF ;
EXIT ;
END IF ;
END LOOP ;
ELSE
EXIT ;
END IF ;
END LOOP ;
END IF ;
RETURN TC$Table ;
END Get_Xml_Tag ;
END Pkg_Tools;
/Then the call:
DECLARE
LC$t VARCHAR2(2000);
LT$Table Pkg_Tools.TYP_TAB_CHAR ;
BEGIN
lc$t := '<?xml version="1.0" encoding="UTF-8"?><WSAnswerTO><error>false</error><errorMessage></errorMessage><results>'
||'<CardTypeTO><carTypId>3</carTypId><TYPE>AMERICAN EXPRESS</TYPE><numLength>15</numLength><cvvLength>4</cvvLength>'
||'<comments>1 800-639-0002</comments></CardTypeTO><CardTypeTO><carTypId>4</carTypId><TYPE>DISCOVER</TYPE>'
||'<numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-347-2683</comments></CardTypeTO>'
||'<CardTypeTO><carTypId>1</carTypId><TYPE>MASTERCARD</TYPE><numLength>16</numLength><cvvLength>3</cvvLength>'
||'<comments>1 800-633-7367</comments></CardTypeTO><CardTypeTO><carTypId>2</carTypId><TYPE>VISA</TYPE>'
||'<numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-945-2000</comments></CardTypeTO></results></WSAnswerTO>' ;
LT$Table := Pkg_Tools.Get_Xml_Tag(LC$T,'<TYPE>') ;
IF LT$Table.COUNT > 0 THEN
FOR i IN LT$Table.First .. LT$Table.Last LOOP
dbms_output.put_line( 'Table(' || i || ')=' || LT$Table(i) ) ;
END LOOP ;
ELSE
dbms_output.put_line( 'tag xml not found' ) ;
END IF ;
END;Francois
Maybe you are looking for
-
How to edit the list box items in labwindow/​CVI?
how to edit the list box items in labwindow/CVI?
-
Help needed to STOP xml loading
Hi there, I'm pretty new to the action script side of things, have had some help on here already and have also been pulled up for asking for too much help. Well I'm kind of getting the hang of it now, but am having one major problem with the site I'm
-
I recently bought an itunes card and i spent some money in a game. i mean i already had the game and i bought something in the game. but when i checked to see if i got it,it took my money and i didnt get what i bought. please help.
-
Easy config..not work..HA
well...got my copy of 6.x and DELETED everything from my pc ( at home ) (running win 95 ). installed 6.x ..blah. try to use easy config to set tnsname.ora sql*net.ora BANG!...no go...reading the readme.xxx easy config does not WORK..you have to MANUA
-
E Recruiting HRRCF_CANDIDATE_PREVIEW'- Candidate data overview form
Hi I have copied the standard candidate overview screen u2018HRRCF_CANDIDATE_PREVIEWu2019 and created two forms i.e. one for internal and the other for external. The reason is due to adding the 2 additional fieds for the Internal Candidates I think