/**
@forlink 2006-2
*/
import java.sql.*;
public class BookType
{
private Statement bookT;
private String id; /*书架类型的唯一标识,对应数据库的ID*/
private String name; /* 图书类型名*/
public BookType()
{
}
/**
Access method for the id property.
@return the current value of the id property
*/
public String getId()
{
return id;
}
/**
Sets the value of the id property.
@param aId the new value of the id property
*/
public void setId(String aId)
{
id = aId;
}
/**
Access method for the name property.
@return the current value of the name property
*/
public String getName()
{
return name;
}
/**
Sets the value of the name property.
@param aName the new value of the name property
*/
public void setName(String aName)
{
name = aName;
}
static int mode = 1;
static String sID = "TP312";
static String sName = "计算机";
/**
书架查询
*/
public void SelectBT(int Mode)
{
mode = Mode;
sID = id;
sName = name;
try
{
DbConnect driver = new DbConnect();
BookType query = new BookType ();
ResultSet rs;
String sqlCommand = "";
driver.setURL("jdbc:odbc:book");
driver.setUser("");
driver.setPassword("");
Connection con = driver.getConnection();
query.setStatement(con);
if(mode == 1) /*按ID查询*/
{
sqlCommand = "select * from BookType where id = '" + sID + "'" ;
}
else
if(mode == 2) /*按name查询*/
{
sqlCommand = "select * from BookType where name = '" + sName + "'";
}
rs = query.executeQuery(sqlCommand);
rs.next();
System.out.println("查询结果如下:");
System.out.println("ID \t" + "Name \t\t" + "valid_flag" + "\t" + "UpDate_time");
for(int i = 0; i<rs.getRow(); i++)
{
System.out.println(rs.getString("id") + "\t" + rs.getString("name") +"\t\t" +
rs.getString("valid_flag") + "\t" + rs.getString("update_time"));
rs.next();
}
rs.close();
query.closeStatement();
con.close();
}
catch (Exception e)
{
System.out.println(e.toString());
}
}
public void setStatement(Connection con)
{
try
{
this.bookT = con.createStatement();
}
catch (Exception e)
{
System.out.println(e.toString());
}
}
public ResultSet executeQuery(String sqlCommand)
{
try
{
return bookT.executeQuery(sqlCommand);
}
catch (Exception e)
{
System.out.println(e.toString());
}
return null;
}
public void closeStatement()
{
try
{
bookT.close();
}
catch (Exception e)
{
System.out.println(e.toString());
}
}
/**
书架更新
*/
static String uID="" ;
static String uName="" ;
public void UpdateBT(String id,String name)
{
uID=id ;
uName=name ;
try
{
DbConnect driver=new DbConnect();
BookType update=new BookType ();
ResultSet rs;
String sqlCommand;
driver.setURL("jdbc:odbc:book");
driver.setUser("");
driver.setPassword("");
Connection con=driver.getConnection();
update.setStatement(con);
sqlCommand="UPDATE BookType SET name='"+uName+"' where id ='"+uID+"'";
rs=update.executeQuery(sqlCommand);
sqlCommand = "select * from BookType" ;
rs=update.executeQuery(sqlCommand);
rs.next();
System.out.println("更新结果如下:");
System.out.println("ID \t" + "Name \t\t" + "valid_flag" + "\t" + "UpDate_time");
for(int i = 0; i<rs.getRow(); i++)
{
System.out.println(rs.getString("id") + "\t" + rs.getString("name") +"\t\t" +
rs.getString("valid_flag") + "\t" + rs.getString("update_time"));
rs.next();
}
rs.close();
update.closeStatement();
con.close();
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
}
booktypemanage.rar_access_java access 书
版权申诉
139 浏览量
2022-09-20
13:50:59
上传
评论
收藏 14KB RAR 举报
APei
- 粉丝: 63
- 资源: 1万+
最新资源
- WS2-32.lib,在编译程序中可以链接使用
- 秒懂傅里叶变换matlab程序实现过程
- ZEND解密dezender12
- sony 索尼IMX334摄像头模组电路板AD版硬件PCB图(6层板).zip
- 基于flask和echarts融合交易策略的bitfinex可视化微服务.zip
- 包含了wvp-assist.tar wvp-talk.tar zlmediakit.tar .
- 3r4efgh53wgrf43tw
- 2024新版Java基础从入门到精通全套视频+资料下载
- Spring AI大模型视频教程+ChatGPT视频教程+OpenAI大模型视频教程(资料+视频教程)
- ABB工业机器人教程PDF版本
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0