title: SQLXML is not working from java
body: <p>Environment Details are : - </p>
  
  <blockquote>
    <p>Appserver is : - apache tomcat 8 jre 1.8 (latest as on March 01,2015) 
    Database is MS-SQL Server 2008</p>
  </blockquote>
  
  <p>Below is the Code Snippet: - </p>
  
  <pre><code>&lt;%@ page import="java.util.*,java.io.*,org.xml.sax.* ,javax.xml.*, org.w3c.dom.*, javax.sql.*, javax.xml.transform.*, javax.xml.transform.sax.* "%&gt;
  
  &lt;% 
  java.sql.Connection con;
  java.sql.Statement s;
  java.sql.ResultSet rs;
  java.sql.PreparedStatement pst;
  con=null;s=null;pst=null;rs=null;
  //String url= "jdbc:sqlserver://dB_IP/dBName"; 
  String url= "jdbc:sqlserver://IPADDRESS;databaseName=dBName;integratedSecurity=false;user=userid;password=password;";
  //String url= "jdbc:jtds:sqlserver://dB_IP/dBName";
  String id= "user_id";
  String pass = "password";
  try{
  //Class.forName("net.sourceforge.jtds.jdbc.Driver");
  Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  //con = java.sql.DriverManager.getConnection(url, id, pass);
  con = java.sql.DriverManager.getConnection(url);
  }catch(ClassNotFoundException cnfex){
  cnfex.printStackTrace();
  }
  String sql = null,root1=null,root2=null,content_type="text/xml";
  if(request.getParameter("sql")!=null){sql=request.getParameter("sql");}else{sql="select * from test_table for xml raw, xmldata";}
  if(request.getParameter("root")!=null){root1=request.getParameter("root");root2="&lt;/"+root1+"&gt;";root1="&lt;"+root1+"&gt;";}else{root1="&lt;parse&gt;";root2="&lt;/parse&gt;";}
  if(request.getParameter("contenttype")!=null){content_type=request.getParameter("contenttype");}else{content_type="text/xml";}
  try{
      out.println( "inside try" );
      s = con.createStatement();
      //SQLXML xmlVal = con.createSQLXML();
      String query = "select top 100 * from table for xml raw, xmldata";
      rs = s.executeQuery(query);
          while (rs.next()) {
              out.println( "&lt;br/&gt;inside while " + query);
              java.sql.SQLXML sqlxml = rs.getSQLXML(1);
              //InputStream binaryStream = sqlxml.getBinaryStream();
  /*
              java.sql.SQLXML rssFeedXML = rs.getSQLXML(1);
              javax.xml.parsers.DocumentBuilderFactory factory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
              factory.setNamespaceAware(true);
              javax.xml.parsers.DocumentBuilder builder = factory.newDocumentBuilder();
              Document doc = builder.parse(rssFeedXML.getBinaryStream());
              //System.out.println("RSS identifier: " + rssName);
              //out.println(JDBCTutorialUtilities.convertDocumentToString(doc));
              out.println( (doc) );
  */
  /*
  //http://docs.oracle.com/javase/6/docs/api/java/sql/SQLXML.html
  
              Transformer identity = TransformerFactory.newInstance().newTransformer();
              Source source = sqlxml.getSource(null);
              Result result = new StreamResult(System.out);
              identity.transform(source, result);
  */
          }
          out.flush();out = pageContext.pushBody();
          out.println( "Hi " );
  }
  catch(Exception e){e.printStackTrace();out.println( "&lt;br/&gt;Caught " + e);}
  finally{
  if(rs!=null) rs.close();
  if(s!=null) s.close();
  if(con!=null) con.close();
  }
  
  %&gt;
  </code></pre>
  
  <p>Compilation Error occurred: - </p>
  
  <blockquote>
    <p>Caught com.microsoft.sqlserver.jdbc.SQLServerException: The conversion
    from ntext to SQLXML is unsupported.</p>
  </blockquote>
  
  <p>"and the Requirement is to": - 
  return an xml document from the select statement.
  xml application is what is required.</p>
  
  <p><strong>If there are any suggestions instead of this approach you can let me know.</strong></p>