📄 adminserviceimpl.java
字号:
package test.service;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import test.util.DbConnectionService;
import test.vo.AdminInfo;
public class AdminServiceImpl implements IAdminService {
private Connection connection;
private Statement statement;
private ResultSet resultSet;
public AdminServiceImpl() {
connection = DbConnectionService.getConnection();
try {
statement = connection.createStatement();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public List<AdminInfo> getAdmin(AdminInfo adminInfo) {
String sql = "select * from admininfo where admin_name='"
+ adminInfo.getAdmin_name() + "' and admin_password='"
+ adminInfo.getAdmin_password() + "'";
List<AdminInfo> list = new ArrayList<AdminInfo>();
try {
resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
list.add(new AdminInfo(resultSet.getInt(1), resultSet
.getString(2), resultSet.getString(3)));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -