/*
CODE GENERATED BY: GRAFXSOFTWARE CODE GENERATOR
http://www.grafxsoftware.com
======================================
CLASS MADE BY: {AUTHOR}
DATE: {DATE}
PROJECT: {PROJECT_NAME}
======================================
*/
/*
{NAME} {CLASSVAR}=new {NAME}();
<!-- BEGIN DYNAMIC BLOCK: getfunctionsvar -->
{CLASSVAR}.get{FUNC_NAME}();
<!-- END DYNAMIC BLOCK: getfunctionsvar -->
<!-- BEGIN DYNAMIC BLOCK: setfunctionsvar -->
{CLASSVAR}.set{FUNC_NAME}();
<!-- END DYNAMIC BLOCK: setfunctionsvar -->
{CLASSVAR}.save();
*/
package {PACKAGE};
import Config;
import java.sql.*;
import ro.grafx.utils.StringUtil;
public class {NAME}
{
<!-- BEGIN DYNAMIC BLOCK: row -->
private {VARIABLES_TYPE} {VARIABLES};
<!-- END DYNAMIC BLOCK: row -->
private Connection con;
public {NAME}(int {IDCLASS}, Connection con)
throws SQLException
{
this.{IDCLASS} = {IDCLASS};
this.con =con;
if(this.{IDCLASS}!=0)
{
Statement statement = con.createStatement();
StringBuffer stringbuffer = new StringBuffer();
stringbuffer.append("SELECT {LIST} FROM {DBNAME} WHERE `{IDCLASS}`=");
stringbuffer.append({IDCLASS});
ResultSet resultset = statement.executeQuery(stringbuffer.toString());
if(resultset.next())
{
<!-- BEGIN DYNAMIC BLOCK: value -->
this.{FIELD_NAME} = resultset.get{TYPE}("{FIELD_NAME}");
<!-- END DYNAMIC BLOCK: value -->
} else
{
<!-- BEGIN DYNAMIC BLOCK: nullvalue -->
this.{FIELD_NAME} = {FIELD_NAME_VALUE};
<!-- END DYNAMIC BLOCK: nullvalue -->
}
resultset.close();
statement.close();
}
} //end constructor
<!-- BEGIN DYNAMIC BLOCK: getfunctions -->
public {FUNC_NAME_TYPE} get{FUNC_NAME}()
{
return this.{VAR_NAME};
}// end get{FUNC_NAME}()
<!-- END DYNAMIC BLOCK: getfunctions -->
<!-- BEGIN DYNAMIC BLOCK: setfunctions -->
public void set{FUNC_NAME}({FUNC_NAME_TYPE} {VAR_NAME})
{
this.{VAR_NAME}={VAR_NAME};
} // end set{FUNC_NAME}()
<!-- END DYNAMIC BLOCK: setfunctions -->
public void save()
throws SQLException
{
Statement statement = con.createStatement();
StringBuffer stringbuffer = new StringBuffer();
StringUtil su=new StringUtil();
if(this.{IDCLASS} == 0)
{
stringbuffer.setLength(0);
stringbuffer.append("INSERT INTO {DBNAME} ({LIST}) VALUES(");
<!-- BEGIN DYNAMIC BLOCK: insert -->
stringbuffer.append("{ENTER}");
stringbuffer.append({VAR_NAME});
stringbuffer.append("{EXIT}");
<!-- END DYNAMIC BLOCK: insert -->
stringbuffer.append(")");
int test=statement.executeUpdate(stringbuffer.toString());
if(test>0)
{
stringbuffer.setLength(0);
stringbuffer.append("SELECT max({IDCLASS}) as max FROM {DBNAME};");
ResultSet resultset = statement.executeQuery(stringbuffer.toString());
if(resultset.next())
this.{IDCLASS}=resultset.getInt("max");
else
this.{IDCLASS}=0;
resultset.close();
}
else
this.{IDCLASS}=0;
statement.close();
return;
} else
{
stringbuffer.setLength(0);
stringbuffer.append("UPDATE {DBNAME} SET ");
<!-- BEGIN DYNAMIC BLOCK: update -->
stringbuffer.append("{ENTER}");
stringbuffer.append({VAR_NAME});
stringbuffer.append("{EXIT}");
<!-- END DYNAMIC BLOCK: update -->
stringbuffer.append(" WHERE `{IDCLASS}`=");
stringbuffer.append(this.{IDCLASS});
statement.executeUpdate(stringbuffer.toString());
return;
}
} //end save()
public void delete()
throws SQLException
{
Statement statement = con.createStatement();
StringBuffer stringbuffer = new StringBuffer();
stringbuffer.setLength(0);
stringbuffer.append("DELETE FROM {DBNAME} WHERE `{IDCLASS}`=");
stringbuffer.append(this.{IDCLASS});
statement.executeUpdate(stringbuffer.toString());
statement.close();
} // end delete()
} //end {NAME}
|