4.19

复制代码
package com;

import java.sql.*;

public class DB {
    public Connection conn = null;
    public Statement stmt = null;
    public ResultSet rs = null;
    String url = "jdbc:mysql://localhost:3306/subway?useSSL=false&serverTimezone=UTC";
    String username = "root";
    String password = "ydt041113";
    public DB(){
        try{
            Class.forName("com.mysql.cj.jdbc.Driver");
            conn = DriverManager.getConnection(url,username,password);
            stmt = conn.createStatement();
        }catch(SQLException se){
            // 处理 JDBC 错误
            se.printStackTrace();
        }catch(Exception e){
            // 处理 Class.forName 错误
            e.printStackTrace();
        }
    }
    public void close(){
        try {
            if (rs!=null){
                rs.close();
            }
            if (stmt!=null){
                stmt.close();
            }
            if (conn!=null){
                conn.close();
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }


}
复制代码
 SubwayBean 

复制代码
package com;

public class SubwayBean {

    public String _StartStation;
    public String _EndStation;
    public Object _Number;
    public String _Path;
}
复制代码

 

posted @     阅读(5)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
点击右上角即可分享
微信分享提示