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

📄 news_manager.java

📁 struts框架编写的例程;学习struts的一个很好程序
💻 JAVA
字号:
package cn.edu.bit.business;

import java.util.GregorianCalendar;

import cn.edu.bit.DBQuery.DataProcess;

/**
 * 
 * @author liuyu 2007-7-21
 */
public class News_Manager {

	/**
	 * 
	 * @param title
	 * @param content
	 */
	public static void Add_News(String title, String content) {
		GregorianCalendar gc = new GregorianCalendar();

		// try
		// {
		// title=new String(title.getBytes("ISO8859_1"));
		//		
		// content=new String(content.getBytes("ISO8859_1"));
		// }
		// catch(Exception e)
		// {
		// e.printStackTrace();
		// }
		//		

		String query = "insert into news(title,content,datetime)values('"
				+ title + "','" + content + "','"
				+ gc.getTime().toLocaleString() + "')";

		try {
			DataProcess.ExeQuery(query);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	/**
	 * 
	 * @param title
	 * @param content
	 * @param id
	 */
	public static void Edit_News(String title, String content, int id) {
		GregorianCalendar gc = new GregorianCalendar();

		// try
		// {
		// title=new String(title.getBytes("ISO8859_1"));
		//		
		// content=new String(content.getBytes("ISO8859_1"));
		// }
		// catch(Exception e)
		// {
		// e.printStackTrace();
		// }

		String query = "update news set title='" + title + "',content='"
				+ content + "',datetime='" + gc.getTime().toLocaleString()
				+ "' where id=" + id;

		try {
			DataProcess.ExeQuery(query);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 
	 * @param id
	 */

	public static void Delete_News(int id) {
		String deleteStr = "delete from news where id=" + id;

		try {
			DataProcess.ExeQuery(deleteStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

⌨️ 快捷键说明

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