DODS FAQs - How can I use DODS without Enhydra?
dods.gif (11357 bytes)Many people have wanted to use the code generated by DODS in a non-Enhydra application. That is, people want to use the DO and Query classes generated by DODS in an application that does not extend Enhydra's StandardApplication class.

The problem is that the the DO and Query classes make calls to Enhydra.getDatabaseManager() and this call returns null if no Application object is registered for the current thread. With a null DatabaseManager, the DO and Query classes cannot talk to the database.

The simplest workaround is not a workaround: just use Enhydra as it was designed to be used.

Here's the minimal Enhydra application:

	public class MyApp extends StandardApplication {
		public MyApp() {
			super();
		}
		public static void main( String[] args ) {
			/*
			 * When starting the app,
			 * pass the name of the .conf file.
			 * See any Enhydra demo app for an example .conf file.
			 */
			String configFilename = args[0];
			ConfigFile config = new ConfigFile(
				    new FileInputStream( configFilename ) );
			MyApp app = new MyApp();
			app.config = config.getConfig();
			StandardLogger logger = new StandardLogger( true );
			app.setLogChannel( logger.getChannel( "" ) );
			app.startup( app.config );
		}
	}

Small Enhydra applications are very useful for writing unit tests that exercise business objects which in turn exercise DO and Query classes that were generated by DODS. (And large applications are often derived from smaller applications.)

An alternative is to hack a bunch of the classes in the com.lutris.appserver.server.sql package so that they have no dependencies on the Logger facility. This is ugly and not recommended.

For all the latest information on DODS, please refer to http://dods.enhydra.org
Questions, comments, feedback? Let us know...