⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 introducedao.java

📁 java web网络编程示例,原代码资源
💻 JAVA
字号:
package edu.liusong.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import edu.liusong.common.DBConnect;
import edu.liusong.mo.Introduce;

public class IntroduceDAO {
	private DBConnect conn;

	private ResultSet rs;

	public Introduce get(String id) {
		Introduce intro = null;
		try {
			conn = new DBConnect();
			String sql = "select * from introduce where id=?";
			String[] values = { id };
			rs = conn.executeQuery(sql, values);
			if (rs.next()) {
				intro = new Introduce();
				intro.setId(rs.getString(1));
				intro.setName(rs.getString(2));
				intro.setContent(rs.getString(3));
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (conn != null)
				try {
					conn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
		}

		return intro;
	}

	public void update(Introduce intro){
		try {
			conn=new DBConnect();
			String sql="update introduce set content=? where id=?";
			String []values={intro.getContent(),intro.getId()};
			conn.executeUpdate(sql, values);
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			if(conn!=null){
				try {
					conn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -