1 16 19 import javax.xml.transform.TransformerFactory ; 21 import javax.xml.transform.Transformer ; 22 import javax.xml.transform.stream.StreamSource ; 23 import javax.xml.transform.stream.StreamResult ; 24 import javax.xml.transform.TransformerException ; 25 import javax.xml.transform.TransformerConfigurationException ; 26 27 import org.apache.xalan.lib.sql.DefaultConnectionPool; 28 import org.apache.xalan.lib.sql.ConnectionPoolManager; 29 30 31 import java.io.StringReader ; 33 import java.io.FileOutputStream ; 34 import java.io.FileNotFoundException ; 35 import java.io.IOException ; 36 37 41 public class ExternalConnection 42 { 43 public static void main(String [] args) 44 throws TransformerException , TransformerConfigurationException , 45 FileNotFoundException , IOException 46 { 47 48 DefaultConnectionPool cp = new DefaultConnectionPool(); 51 cp.setDriver("org.enhydra.instantdb.jdbc.idbDriver"); 52 cp.setURL("jdbc:idb:../../instantdb/sample.prp"); 53 cp.setMinConnections(10); 56 cp.setPoolEnabled(true); 57 58 ConnectionPoolManager pm = new ConnectionPoolManager(); 61 pm.registerPool("extpool", cp); 62 63 64 TransformerFactory tFactory = TransformerFactory.newInstance(); 69 70 Transformer transformer = tFactory.newTransformer( 74 new StreamSource ("dbtest.xsl")); 75 76 StringReader reader = 81 new StringReader ("<?xml version=\"1.0\"?> <doc/>"); 82 83 transformer.transform( 86 new StreamSource (reader), 87 new StreamResult (new FileOutputStream ("dbtest-out.html"))); 88 89 System.out.println("************* The result is in dbtest-out.html *************"); 90 91 cp.setPoolEnabled(false); 92 } 93 } 94 | Popular Tags |