📄 workgroup.java
字号:
package com.am;
import java.util.*;
import java.sql.*;
import java.text.*;
public class workgroup
{
public long ID;
public String note;
public String fieldName;
public int tag;
private String strSql;
private Connection dbConn;
private int errNum;
private String errDesc;
private SimpleDateFormat dateFormatter;
public void workgroup()
{
ID=0;
note="";
fieldName="";
tag=0;
strSql="";
errNum=0;
errDesc="";
}
public void add()
{
strSql="insert into workgroup ";
strSql=strSql + "(";
strSql=strSql + "note,";
strSql=strSql + "fieldName,";
strSql=strSql + "tag";
strSql=strSql + ") ";
strSql=strSql + "values(";
strSql=strSql + "'" + note + "',";
strSql=strSql + "'" + fieldName + "',";
strSql=strSql + "'" + tag + "'";
strSql=strSql + ")";
exeSql(strSql);
}
public void delete()
{
strSql="delete from workgroup where ID='";
strSql=strSql + this.ID + "'";
exeSql(strSql);
}
public boolean isExist()
{
strSql="select * from `workgroup` ";
strSql=strSql + " where note='" + this.note + "'";
try
{
Statement stmt=dbConn.createStatement();
ResultSet rs =stmt.executeQuery(strSql);
if(rs.next())
{
this.errNum=0;
this.errDesc="" ;
return true;
}
else
{
this.errNum=-1;
this.errDesc="the note didn't exist!!";
return false;
}
}
catch(Exception ex)
{
this.errNum=-1;
this.errDesc=ex.toString();
return true;
}
finally
{
}
}
public void updateWorkgroup()
{
strSql="update workgroup set";
strSql=strSql + " note='"+ note + "',";
strSql=strSql + " fieldName='"+ fieldName + "'";
strSql=strSql + " where ID='" + ID + "'";
exeSql(strSql);
}
public boolean init()
{
strSql="select * from workgroup where ID=";
strSql=strSql + "'" + this.ID + "'";
try
{
Statement stmt=dbConn.createStatement();
ResultSet rs =stmt.executeQuery(strSql);
if (rs.next())
{
ID=rs.getLong("ID");
note=rs.getString("note");
fieldName=rs.getString("fieldName");
tag=rs.getInt("tag");
this.errNum=0;
this.errDesc="";
return true;
}
else
{
this.errNum=-1;
this.errDesc="init faild!";
return false;
}
}
catch(Exception ex)
{
this.errNum=-1;
this.errDesc=ex.toString();
return false;
}
}
public void setConnection(Connection dbConn)
{
this.dbConn=dbConn;
}
private void exeSql(String strSql)
{
Statement stmt=null;
try
{
stmt=dbConn.createStatement();
stmt.executeUpdate(strSql);
this.errNum=0;
this.errDesc="";
}
catch(Exception ex)
{
System.out.println(ex.toString());
this.errNum=-1;
this.errDesc=ex.toString();
}
finally
{
stmt=null;
}
}
public int getErrNum()
{
return errNum;
}
public String getErrDesc()
{
return errDesc;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -