Code Generator for Eclipse Code
Brought to you by:
hotzst
import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; /** * This DAO class provides access to the * Oracle table <c:get select="/table/@name" /> by * several defined methods thus abstracting the * database access.<br> * The transaction is set to prevent dirty reads, non-repeatable * reads and phantom reads. The autocommi-flag is set, meaning * that a commit is executed after every update, insert or * delete statement. */ public class <c:get select="camelCase(/table/@formatname)" />DAO { /** * Connection to the database */ private Connection con=null; /** * Statement on which the statements are executed */ private Statement stmt=null; /** * Default constructor initialized the connection * @param db_url URL of the database e.g. localhost * @param username name of the user to log into the database * @param password password for <code>username</code> to log into the database * @throws ClassNotFoundException the JDBC driver could not be loaded. * Make sure the correct library is on your classpath * @param SQLException The connection could not be established or the statement created. */ public <c:get select="camelCase(/table/@formatname)" />DAO(String db_url, String username, String password) throws ClassNotFoundException, SQLException{ Class.forName("com.oracle.jdbc.OracleDriver"); con = DriverManager.getConnection(db_url, username, password); con.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); con.setAutoCommit(true); stmt = con.createStatement(); } public int update(){ String statement = "UPDATE <c:get select="/table/@name" /> SET <%-- <c:iterate select="/table/tabledef/field" var="f"><c:get select="$f/@name" /> = "+<c:get select="lc(camelCase(/table/@formatname))" />.get<c:get select="camelCase($f/@formatname)" />(), </c:iterate> --%> } public int insert(){ } public int delete(){ } <c:iterate select="/table/indexdef/index" var="i"> <c:if test="$i/@constraint='UNIQUE'"> public <c:get select="camelCase(/table/@formatname)" /> loadUniqueBy<c:get select="$i/@name" />( <c:iterate select="$i/field" var="f"> </c:iterate> </c:if> </c:iterate> }