adminserviceimpl.java

来自「JavaBean+Servlet+jsp开发的《网上购物系统》」· Java 代码 · 共 52 行

JAVA
52
字号
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 + =
减小字号Ctrl + -
显示快捷键?