📄 companydao.java
字号:
package com.dao;
import com.tool.JDBConnection;
import com.domain.CompanyVO;
import java.sql.*;
//本公司表的操作
public class CompanyDao {
private JDBConnection connection = null;
public CompanyDao() {
connection = new JDBConnection();
this.connection.creatConnection(); //利用构造方法调用类中的对象对数据库创建连接
}
//修改内容
public void updateCompany(CompanyVO vo) {
String sql = "update tb_company set name='" + vo.getName() + "',tel='" +
vo.getTel() +
"',address='" + vo.getAddress() + "',manager='" + vo.getManager() +
"',fax='" + vo.getFax() + "',tenet='" + vo.getTenet() + "',culture='" +
vo.getCulture() + "',intro='" + vo.getIntro() + "' where id='" +
vo.getId() + "'";
connection.executeUpdate(sql);
connection.closeConnection();
}
//公司表的内容的查询
public CompanyVO selectCompany() {
CompanyVO company = null;
String sql = "select * from tb_company";
ResultSet rs = connection.executeQuery(sql);
try {
while (rs.next()) {
company = new CompanyVO();
company.setId(Integer.valueOf(rs.getString(1)));
company.setName(rs.getString(2));
company.setTel(rs.getString(3));
company.setAddress(rs.getString(4));
company.setManager(rs.getString(5));
company.setFax(rs.getString(6));
company.setTenet(rs.getString(7));
company.setCulture(rs.getString(8));
company.setIntro(rs.getString(9));
}
}
catch (SQLException ex) {
}
connection.closeConnection();
return company;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -