Oct 11

The DBUtil library from Apache provides a set of class for doing a variety of standard database tasks.

eg. To make a query becomes as simple as the following, providing the result set as a List of arrays where each list elements contains a row.

QueryRunner runner = new QueryRunner();
ArrayListHandler handler = new ArrayListHandler();
List<Object[]> result = runner.query(connection,
    "SELECT * FROM MyTable WHERE name=?", handler, "Joe Smith");

written by objects \\ tags: , , , ,

Mar 27

To use anonymous access for an LDAP search or query set the value of Context.SECURITY_AUTHENTICATION to “none” in the environment used to create the initial context.

Hashtable env = new Hashtable();
env.put(Context.PROVIDER_URL, providerUrl);

// Use 'none' for anonymous access
env.put(Context.SECURITY_AUTHENTICATION, "none");

// Create the initial context
DirContext ctx = new InitialDirContext(env);

written by objects \\ tags: , , ,

Oct 01

You need to build it manually from the ServletRequest.

StringBuilder sb = new StringBuilder("?");
for (Enumeration e = request.getParameterNames(); 
      String param = (String) e.nextElement();
String queryString = sb.toString().
   substring(0, sb.length() - 1); 

written by objects \\ tags: , ,