📄 tchannelimpl.java
字号:
package com.sxit.pim.channel;
import java.util.*;
import java.sql.*;
/**
* <p>类名: TchannelImpl</p>
* <p>功能: channel</p>
* <p>公司: 深讯信科</p>
* <p>版本: 1.0</p>
* @程序 sxit
* @日期 2005-12-14
* @修改纪录
*/
public class TchannelImpl
{
public TchannelImpl()
{
super();
}
private int id;
private int cp_id;
private String channel_name;
private String cpname;
private String channelid;
private long corporationid;
private String name;
public void setId(int id)
{
this.id = id;
}
public int getId()
{
return id;
}
public void setCp_id(int cp_id)
{
this.cp_id = cp_id;
}
public int getCp_id()
{
return cp_id;
}
public void setCpname(String cpname)
{
this.cpname = cpname;
}
public String getCpname()
{
return cpname;
}
public void setChannelid(String channelid)
{
this.channelid = channelid;
}
public String getChannelid()
{
return channelid;
}
public void setChannel_name(String channel_name)
{
this.channel_name = channel_name;
}
public String getChannel_name()
{
return channel_name;
}
public void setCorporationid(long corporationid)
{
this.corporationid = corporationid;
}
public long getCorporationid()
{
return corporationid;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
/**
* 创建数据,需要初始化类
*/
public void create(Connection con,int id) throws SQLException
{
PreparedStatement stmt=null;
ResultSet rs=null;
String sql="";
try{
sql="select a.id,b.cp_name,a.channel_name,a.corporationid,a.cp_id,a.channelid from tchannel a,tcp b where a.id=?";
stmt=con.prepareStatement(sql);
stmt.setInt(1,id);
rs=stmt.executeQuery();
if(rs.next()){
this.id = rs.getInt("id");
cpname = rs.getString("cp_name");
channelid=rs.getString("channelid");
channel_name = rs.getString("channel_name");
corporationid = rs.getLong("corporationid");
cp_id=rs.getInt("cp_id");
}
stmt.close();
}
finally{
if(stmt!=null) stmt.close();
}
}
/**
* 插入数据,无需要初始化类
*/
public static int insert(Connection con,int id,int cp_id,String channel_name,long corporationid,String channelid) throws SQLException
{
PreparedStatement stmt=null;
String sql="";
int cnt=0;
try
{
sql="insert into tchannel "+
"(id,cp_id,channel_name,corporationid,channelid) "+
"values (?,?,?,?,?)";
stmt=con.prepareStatement(sql);
stmt.setInt(1, id);
stmt.setInt(2, cp_id);
stmt.setString(3, channel_name);
stmt.setLong(4 , corporationid);
stmt.setString(5,channelid);
cnt=stmt.executeUpdate();
stmt.close();
}
finally
{
if(stmt!=null) stmt=null;
}
return cnt;
}
/**
* 插入数据,需要初始化类,并将设置类的域
*/
public int insert(Connection con) throws SQLException
{
PreparedStatement stmt=null;
String sql="";
int cnt=0;
try
{
sql="insert into tchannel "+
"(id,cp_id,channel_name,corporationid) "+
"values (?,?,?,?)";
stmt=con.prepareStatement(sql);
stmt.setInt(1, id);
stmt.setInt(2, cp_id);
stmt.setString(3, channel_name);
stmt.setLong(4, corporationid);
cnt=stmt.executeUpdate();
stmt.close();
}
finally
{
if(stmt!=null) stmt=null;
}
return cnt;
}
/**
* 更新数据,无需要初始化类
*/
public static int update(Connection con,int id,int cp_id,String channel_name,long corporationid) throws SQLException
{
PreparedStatement stmt=null;
String sql="";
int cnt=0;
try
{
sql="update tchannel set cp_id=?,channel_name=?,corporationid=? where id=?";
stmt=con.prepareStatement(sql);
stmt.setInt(1, cp_id);
stmt.setString(2, channel_name);
stmt.setLong(3, corporationid);
stmt.setInt(4, id);
cnt=stmt.executeUpdate();
stmt.close();
}
finally
{
if(stmt!=null) stmt=null;
}
return cnt;
}
/**
* 更新数据,需要初始化类,并将设置类的域
*/
public int update(Connection con) throws SQLException
{
PreparedStatement stmt=null;
String sql="";
int cnt=0;
try
{
sql="update tchannel set cp_id=?,channel_name=?,corporationid=?,channelid=? where id=?";
stmt=con.prepareStatement(sql);
stmt.setInt(1, cp_id);
stmt.setString(2, channel_name);
stmt.setLong(3, corporationid);
stmt.setString(4,channelid);
stmt.setInt(5, id);
cnt=stmt.executeUpdate();
stmt.close();
}
finally
{
if(stmt!=null) stmt=null;
}
return cnt;
}
/**
* 删除一条数据
*/
public static int delete(Connection con,int id) throws SQLException
{
PreparedStatement stmt=null;
String sql="";
int cnt=0;
try{
sql="delete from tchannel where id=?";
stmt=con.prepareStatement(sql);
stmt.setInt(1,id);
cnt=stmt.executeUpdate();
stmt.close();
}
finally{
if(stmt!=null) stmt.close();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -