第二次冲刺 02

今日进行站立会议,主要是对于下一步的进行做出规划要求。

如何优化整个项目的进程进行分析。

昨天写错地方了。。。。

复制代码
package com.example.math.repositiory;

import com.example.math.jdbc.JDBCtools;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class Mer_login {
    public static List<String> findAllName() throws Exception {
        List<String> list = new ArrayList<>();
        Connection conn = JDBCtools.getConnect();
        PreparedStatement pre = null;
        ResultSet res = null;
        String sql = "select mer_phone from mer_login";
        try {
            pre = conn.prepareStatement(sql);
            res = pre.executeQuery();
            while (res.next()) {
                String name = res.getString("mer_phone");
                list.add(name);
            }

        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            JDBCtools.release(conn, pre, res);
        }
        return list;
    }

    public static String findAddress(String mer_name) throws Exception {
        Connection connection = JDBCtools.getConnect();
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;
        String address = null;
        String sql = "select address from mer_login where mer_phone = ?";
        try {
            preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setString(1,mer_name);
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()){
                address = resultSet.getString("address");
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }finally {
            JDBCtools.release(connection,preparedStatement,resultSet);
        }
        return address;
    }
}
复制代码

 

 

posted @   SWJxx  阅读(10)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
· 使用C#创建一个MCP客户端
点击右上角即可分享
微信分享提示