All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mentawai.db.AbstractConnectionHandler Maven / Gradle / Ivy

Go to download

A Java full-stack web framework with programmatic configuration instead of XML and Annotations.

There is a newer version: 2.5.6
Show newest version
package org.mentawai.db;

import java.sql.Connection;

public abstract class AbstractConnectionHandler implements ConnectionHandler {
	
	@Override
	public void exec(Exec exec) {
		Connection conn = null;
		try {
			conn = getConnection();
			exec.exec(conn);
		} catch(Exception e) {
			throw new RuntimeException(e);
		} finally {
			release(conn);
		}
	}
	
	@Override
    public  T getInstance() {
		try {
	    	
    		return (T) getConnection();
    		
    	} catch(Exception e) {
    		
    		throw new RuntimeException(e);
    	}
    }

	@Override
    public Class getType() {
		return Connection.class;
    }

	@Override
    public void onCreated(Connection createdObject) {
		// nothing here
    }

	@Override
    public void onCleared(Connection clearedObject) {
	    release(clearedObject);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy