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

📄 systeminfoado.java

📁 Java项目开发与毕业设计指导 朱福喜, 黄昊编著 清华大学出版社 项目2
💻 JAVA
字号:
package ado;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import datasource.*;

import iado.SystemInfoIAdo;

public class SystemInfoAdo implements SystemInfoIAdo {
	
	private Connection conn;
	
	public SystemInfoAdo() throws SQLException{
		conn = DBConnection.getConnection();
	}

	public String selectBulletin() throws SQLException{
		try {
			PreparedStatement pst = conn
					.prepareStatement("select * from SystemInfo");
			ResultSet rs = pst.executeQuery();
			if(rs.next())
				return rs.getString(1);
		} catch (SQLException e) {
			e.printStackTrace();
			throw e;
		}
		return null;
	}

	public int selectRowsPerPage() throws SQLException{
		try {
			PreparedStatement pst = conn
					.prepareStatement("select * from SystemInfo");
			ResultSet rs = pst.executeQuery();
			if(rs.next())
				return rs.getInt(2);
		} catch (SQLException e) {
			e.printStackTrace();
			throw e;
		}
		return 10;
	}

	public void updateBulletin(String bulletin) throws SQLException{
		try {
			PreparedStatement pst = conn
					.prepareStatement("update SystemInfo set bulletin=?");
			pst.setString(1,bulletin);
		    pst.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
			throw e;
		}
	}

	public void updateRowsPerPage(int rowsPerPage) throws SQLException{
		try {
			PreparedStatement pst = conn
					.prepareStatement("update SystemInfo set RowsPerPage=?");
			pst.setInt(1,rowsPerPage);
			pst.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
			throw e;
		}
	}
	
	public void close() throws SQLException{
		if(conn!=null)
			conn.close();
	}

}

⌨️ 快捷键说明

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