Re: Getting FOR XML into Java




<spjo55@xxxxxxxxx> wrote in message
news:1140830038.866049.255580@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello there

I have a question regarding the XML support in SQL Server 2005 and the
new Microsoft JDBC driver. I hope to get XML from SQL Server to do
XSLT-processing at the web-tier, but lack some sample code of how get
XML through JDBC when I do a SELECT .... FOR XML.

In this article
http://www.windowsitpro.com/Article/ArticleID/22324/22324.html Rich
Rollman describes a "character-encoding mismatch between SQL Server
and Java" and suggests this code:

// Display the SQL results.
while(rs.next())
{
InputStream is = rs.getBinaryStream(1);
InputStreamReader isr = new
InputStreamReader(is,"UnicodeLittle");

while ((c = isr.read()) != -1)
{
bw.write(c);
sb.append((char) c);
}
}

The article/code above is from 2001, and my question is how best to
tackle this with SQL Server 2005 and the new driver. I can do it by
building a String in the while loop, but I think that there might be a
better way.

Eventually I will need to pass the XML as a javax.xml.transform.Source
to do the transformation.



I'm not sure what the best way is, but with SQL 2005 you can easilly get the
XML as a string. EG

declare @xml xml
select (select * from sys.objects for xml auto, type)
select cast(@xml as varchar(max)) xml

David


.



Relevant Pages

  • Re: using OpenXML in T-sql?
    ... am not the most senior person in sql server programming, ... especially xml stuff. ... style string in place of an array without the additional ... >delimited strings and opts for the xml string instead. ...
    (microsoft.public.sqlserver.programming)
  • Re: using OpenXML in T-sql?
    ... If you subscribe to SQL Server Professional, ... He suggests you can pass an xml string to the sp (as opposed to an xml doc - values from array would be in an xml string) and use Openxml to retrieve the values in one call rather than looping through an array. ...
    (microsoft.public.sqlserver.programming)
  • Re: Download the JAVA , .NET and SQL Server interview PDF
    ... 2000 Interview questions of .NET, JAVA and SQL Server Interview ... XML Integration ...
    (comp.lang.java.programmer)
  • SQL Server and .NET Interview questions free download
    ... 2000 Interview questions of .NET, JAVA and SQL Server Interview ... XML Integration ...
    (microsoft.public.dotnet.languages.csharp)
  • SQL Server and .NET Interview questions free download
    ... 2000 Interview questions of .NET, JAVA and SQL Server Interview ... XML Integration ...
    (microsoft.public.dotnet.languages.vb)

Loading