File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes sql query stored in the xml, parsed and executed from java - throws malformed exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "sql query stored in the xml, parsed and executed from java - throws malformed exception" Watch "sql query stored in the xml, parsed and executed from java - throws malformed exception" New topic
Author

sql query stored in the xml, parsed and executed from java - throws malformed exception

az ziz
Ranch Hand

Joined: Dec 17, 2008
Posts: 50
dear all,

I store the sql queries like stored proc call query, other queries in an xml, i use this xml to parse an execute appropriate query. I have written dtd for it. assume xml element is like this





in dtd i have given stored-procedure (#PCDATA)

If i include the dtd file in xml and parse the xml the java code and execute the query jdbc throws Malformed SQL92 string at position: 34
If i remove the dtd and run the parser and execute the query it works!
I know that the #PCDATA will parse the text between the tag, how do i make it work?

Thanks for your helps
V
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

My guess would be that different strings are being produced as a result of your parsing. If it were my problem I would be interested in seeing how those strings differ from each other.

Actually any time I got an error message saying my SQL string had a problem, my first idea would be to look at that string. I recommend that.
az ziz
Ranch Hand

Joined: Dec 17, 2008
Posts: 50
thanks for you reply Mr. Clapham,
i had checked the query that is sent to the jdbc statement.
I use apache sax parser


the value string extracted comes differently. how does this happen?
I see that the query string has been lost, before or after in the query string. but what bothers me is that if i did not include the dtd file it works fine, no string is lost, no matter how much big or complex the query be.

is this post changing topic from jdbc to xml parsing?

V
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2495
    
    8

Is the DTD file correct?

I am moving this thread to our XML and Related Technologies forum. The issue we have here is not related to sql, but to parsing XML.

Regards, Jan


OCUP UML fundamental and ITIL foundation
youtube channel
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
You have run into the common misconception about the characters() method.

It does NOT grab all of the characters inside the element reliably. If the text gets split across two buffer-load you get exactly what you are seeing. Including the DTD is changing the way the characters you are interested in fall at buffer boundaries.

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sql query stored in the xml, parsed and executed from java - throws malformed exception