DataC 1.01



Component which supplies data control to Java applications

Full description

DataC is just a bunch of interfaces and abstract classes, which don't look very exciting. Their job is defining a standard Data Modification interface for use in applications. The purpose in design was to have my applications deal with the data objects only and not bother about how, why or when these data objects where actually stored.

namedatezipzip (source)tar.gztar.gz (source)
DataC 1.0121-03-2008DataC-1.01.zipDataC-src-1.01.zipDataC-1.01.tar.gzDataC-src-1.01.tar.gz
DataC 0.30.101-09-2004
DataC 0.3017-04-2004DataC-0.30.zipDataC-0.30.tar.gz

Note: If you want to make a quick start download the .zip or .tar.gz file. It includes the compiled jar and possible dependencies. The sources contains the sources for this specific project and the compiled libraries listed as dependencies.



java 1.4+

Used components

Used libraries

Using DataC

How to use

One of the quickest way to get started using this DataC interface is by using sql2class to generate the data classes from your database and implement a data controller as in the example underneath. This DataController is a singleton used for client-server applications. It uses reflection to find the appropriate DataControl class and can be used to send changed or new data objects to the database:
Controller.getInstance().update(MyTable()); or Controller.getInstance().insert(MyTable()); Selects are about as easy to define. Look at the javadoc to see how to define queries with a Condition object.
import java.lang.reflect.Constructor;
import java.sql.Connection;
import java.util.Properties;
import java.util.Vector;

import org.brains2b.sql.Connector;

public class Controller extends Connector implements DataController {

	private static Controller m_instance;
	protected Controller() {
		try {
			Properties prop = new Properties();
			prop.load(new FileInputStream("conf/"));
		} catch (Exception ex) {

	public static Controller getInstance() {
		if (m_instance == null) {
			m_instance = new Controller();
		return m_instance;
	public int update(Object o) throws Exception {
		DataControl dc = getControlObject(o);
		return dc.update();

	public int insert(Object o) throws Exception {
		DataControl dc = getControlObject(o);
		return dc.insert();

	public int delete(Object o) throws Exception {
		DataControl dc = getControlObject(o);
		return dc.delete();

	public Object retrieve(Object o, Object condition) throws Exception {
		DataControl dc = getControlObject(o);
		Vector v = dc.retrieveList((Condition) condition);
		if (v==null) return null;
		return v.get(0);

	public List retrieveList(Object o, Condition condition) throws Exception {
		DataControl dc = getControlObject(o);
		return dc.retrieveList((Condition) condition);

	protected DataControl getControlObject(Object o) throws Exception {
		Class c = o.getClass();
		String dcName =
				+ "."
				+ c.getName().substring(c.getName().lastIndexOf(".") + 1)
				+ "DC";

		Class dcClass = c.getClassLoader().loadClass(dcName);
		Constructor[] cons = dcClass.getConstructors();
		Constructor con =
				new Class[] { Connection.class, Object.class });
		return (DataControl) con.newInstance(
			new Object[] { getConnection(), o });


Note: You can do a lot more interesting things with DataC, look for instance at the Cursor class, I haven't had time to write proper HOW-TO's or examples for it, but on the other hand, you might be able to figure it out looking at the javadoc and provided Unit tests

Reference implementation/examples


DataC 1.01

  • Waldorf code-review changes
  • Changes to the naming of the interfaces to be less database specific
  • Support for Blob,Clob and streaming data-types in both generated classes and cursor

DataC 0.30.1

  • Speed up making cursor prototype for cursors not using parameters

DataC 0.30

  • Added javadoc and test classes for all classes