Skip to content

Commit

Permalink
Trying to give Vlad proper credit for stuff I cherry-picked across and
Browse files Browse the repository at this point in the history
apparently lost attribution on. This commit may result in crediting
him for some work I did. I honestly don't care.
  • Loading branch information
kubycsolutions committed Jan 1, 2024
1 parent b674b75 commit 287cea7
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
*/
public class ExternalConnection
{
public static void main(String[] args)
public static void main(String[] args)
throws TransformerException, TransformerConfigurationException,
FileNotFoundException, IOException
FileNotFoundException, IOException
{

// Create a connection to the database server
Expand Down Expand Up @@ -100,8 +100,62 @@ public static void main(String[] args)
new StreamSource(reader),
new StreamResult(new FileOutputStream("dbtest-out.html")));

System.out.println("************* The result is in dbtest-out.html *************");

cp.setPoolEnabled(false);
System.out.println("************* The result is in dbtest-out.html *****
// Create a connection to the database server
// Up the connection pool count for testing
DefaultConnectionPool cp = new DefaultConnectionPool();
cp.setDriver("org.apache.derby.jdbc.EmbeddedDriver");
cp.setURL("jdbc:derby:sampleDB");
//cp.setUser("sa");
//cp.setPassword("");
cp.setMinConnections(10);
cp.setPoolEnabled(true);

// Now let's register our connection pool so we can use
// in a stylesheet
ConnectionPoolManager pm = new ConnectionPoolManager();
pm.registerPool("extpool", cp);


// Use the static TransformerFactory.newInstance() method to instantiate
// a TransformerFactory. The javax.xml.transform.TransformerFactory
// system property setting determines the actual class to instantiate --
// org.apache.xalan.transformer.TransformerImpl.
TransformerFactory tFactory = TransformerFactory.newInstance();

// Grab the Name of the Stylesheet from the command line
if (args.length == 0)
{
System.out.println("You must provide the path and name to a stylesheet to process");
System.exit(0);
}

String stylesheet = args[0];
System.out.println("Transforming Stylesheet " + stylesheet);

// Use the TransformerFactory to instantiate a Transformer that will work with
// the stylesheet you specify. This method call also processes the stylesheet
// into a compiled Templates object.
Transformer transformer = tFactory.newTransformer(
new StreamSource(stylesheet));

// For this transformation, all the required information is in the
// stylesheet, so generate a minimal XML source document for the
// input. Note: the command-line processor
// (org.apache.xalan.xslt.Process) uses this strategy when the user
// does not provide an -IN parameter.
StringReader reader =
new StringReader("<?xml version=\"1.0\"?> <doc/>");

// Use the Transformer to apply the associated Templates object to
// an XML document and write the output to a file.
transformer.transform(
new StreamSource(reader),
new StreamResult(new FileOutputStream("dbtest-out.html")));

System.out.println("************* The result is in dbtest-out.html *************");

cp.setPoolEnabled(false);
>>>>>>> 4aa150b2e (Reconcile/rebase)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,4 @@
</DIV></DIV>
</xsl:template>

</xsl:stylesheet>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private static String getLocalName(Node node) {
}

public void parse(InputSource unused) throws IOException, SAXException {
parse(_dom);
parse();
}

public void parse() throws IOException, SAXException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,4 +407,4 @@ public DOM getStylesheetDOM() {
public void setStylesheetDOM(DOM sdom) {
_sdom.set(sdom);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public synchronized XMLReader getXMLReader() throws SAXException {

/**
* Mark the cached XMLReader as available. If the reader was not
* actually in the cache, do nothing.
* for this thread, mark it as no longer being in use.
*
* @param reader The XMLReader that's being released.
*/
Expand Down

0 comments on commit 287cea7

Please sign in to comment.