Skip navigation links

Package net.windward.datasource.jdbc

This supplies a sql data source to Windward Reports.

See: Description

Package net.windward.datasource.jdbc Description

This supplies a sql data source to Windward Reports. This package uses jdbc to perform the real work including all selection of nodes using jdbc. This is the secondary (after the dom4j implementation) reference implementation for the net.windward.datasource package.

An xml file always has the concept of the current node. This is not the case with a sql database - there is no current ResultSet. A ResultSet is only generated by the wr:query and the wr:foreach tags. Therefore, all other tags only make sense if they use the var attribute from a query or foreach to identify the ResultSet they are to be applied to. A tag not identifying a ResultSet will throw an exception.

A query or foreach tag can reference a var from another query or foreach tag using ${var.item}.. An XPath query can describe a node as well as an element. In this class a query defines a ResultSet and is only an element.

Also, with xml you can use xpath in each tag performing complex logic in determining what text to return. It is very different for sql. The foreach or query can have complex logic. But the other tags can only return an element from a result set that the foreach/query earlier returned.

When using a var (<wr:forEach var="result"/>) that identifies a result set, you can use the following in a tag:

An <if select= ... > will return true if the passed in select returns a ResultSet with one or more rows. An <if select="select count (*) from customers" notEmpty="true"> will perform two steps. The first step is it will return false if there are no results returned. If results are returned it assumes the select is a count and will do a return ResultSet.getInt(1) > 0;. This does not look at the select statement, it is the notEmpty="true" that puts it in this mode.

Notes: statements are created using Connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY) The TYPE_SCROLL_SENSITIVE setting is necessary in some jdbc drivers for ResultSet.isLast() to function.

A really good book on JDBC that includes these parameters for creating a connection with most databases is JDBC Pocket Reference from O'Reilly.

Skip navigation links

Copyright © 2017 Windward Reports - All Rights Reserved. We are java reporting software