XML Databases and Tools 1 : XML Database : XML : Java examples (example source code) Organized by topic

Java
C++
PHP
Java Home »  XML   » [  XML Database  ]  Screenshots 
 



XML Databases and Tools 1


/*
  Java, XML, and Web Services Bible
  Mike Jasnowski
  ISBN: 0-7645-4847-6
*/
import java.sql.*;
import java.io.*;
 
public class XMLBlobRead {     
  
     public static void main (String[] args) {
 
          try {
               Class.forName("COM.cloudscape.core.JDBCDriver").newInstance();
           
               Connection conn = DriverManager.getConnection(
                "jdbc:cloudscape:GAMETRADER");
                 
               Statement s = conn.createStatement();
 
               ResultSet rs = s.executeQuery("SELECT * FROM MANUALS");  
                
               while (rs.next()) {
                      int id = rs.getInt("GAMEID");
                      InputStream bis = rs.getAsciiStream("MANUAL");
                      ByteArrayOutputStream bos = new ByteArrayOutputStream();
                      int ch = 0;
                      while ((ch = bis.read())!=-1)
                            bos.write(ch);
                      System.out.println("GAMEID: " + id + "\n" +  
                                         "MANUAL: " new String(bos.toByteArray()));
               }              
 
          }    catch (Throwable e) {
               System.out.println("exception thrown");
               System.out.println(e);
          }
 
     }
 
 
}



           
       
Related examples in the same category
1.  XML Databases and Tools 3
2.  XML Databases and Tools 2
3.  XML Databases DOM








Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.