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

📄 data.java

📁 第1章 大学生就业求职网 第2章 网上物流平台 第3章 华奥汽车销售集团网 第4章 佳美网络购物中心 第5章 科研成果申报管理系统 第6章 安瑞奥国际商务学院招生网 第7章 在线宽带影院
💻 JAVA
字号:
/*
 * Created on 2004-11-30
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package com.bwm.db;

import java.sql.ResultSet;
import java.sql.Statement;

/**
 *class explain:Database connection<br>
 *set up name:	crazyadept<br>
 *set up time:	11/29/2004
 */
public class Data {
	
	private Conn con=new Conn();
	private Statement stmt;
	private ResultSet rs;

	/**
	 *input  parameter:DataBase table name<br>
	 *output parameter:count = -2 ;Exception <br>
	 *				   count = -1 ;Error <br>
	 *				   count = 0  ;Nothing<br>
	 *				   count > 0  ;Right<br>
	 *modify time:	11/29/2004
	 */
	public int getRowCount(String strSql){
		int intCount=0;;
		try{
			stmt=con.getStmtread();
			rs=stmt.executeQuery("SELECT COUNT(*) FROM "+strSql);
			if(rs.next()){
				intCount=rs.getInt(1);
			}else{
				intCount=-1;
			}
		}catch(Exception e){
			intCount=-2;
			System.err.println(e.getMessage());
			e.printStackTrace();
		}finally{
			con.close();
			return intCount;
		}
	}
	
	/**
	 *return	value:	count = -2 >Exception <br>
	 *				count = 0  >nothing<br>
	 *				count > 1  >right<br>
	 *parameter:		SQL<br>
	 *set up name:	crazyadept<br>
     *change time:	11/29/2004
	 */
	public int insert(String sql){
		int count=0;
		stmt=con.getStmt();
		try{
			count=stmt.executeUpdate(sql);
		}catch(Exception e){
			count=-2;
			System.err.println(e.getMessage());
			e.printStackTrace();
		}finally{
			con.close();
			return count;
		}
	}

	/**
	 *return	value:	count = -2 >Exception <br>
	 *				count = 0  >nothing<br>
	 *				count > 1  >right<br>
	 *parameter:		SQL<br>
	 *set up name:	crazyadept<br>
     *change time:	11/29/2004
	 */
	public int update(String sql){
		int count=0;
		stmt=con.getStmt();
		try{
			count=stmt.executeUpdate(sql);
		}catch(Exception e){
			count=-2;
			System.err.println(e.getMessage());
			e.printStackTrace();
		}finally{
			con.close();
			return count;
		}
	}

	/**
	 *return	value:	count = -2 >Exception <br>
	 *				count = 0  >nothing<br>
	 *				count > 1  >right<br>
	 *parameter:		SQL<br>
	 *set up name:	crazyadept<br>
	 *set up time:	11/29/2004<br>
	 *change time:	11/29/2004
	 */
	public int delete(String sql){
		int count=0;
		stmt=con.getStmt();
		try{
			count=stmt.executeUpdate(sql);
		}catch(Exception e){
			count=-2;
			System.err.println(e.getMessage());
			e.printStackTrace();
		}finally{
			con.close();
			return count;
		}
	}

	/**
	 *return	value:	count = -2 >Exception <br>
	 *				count = 0  >nothing<br>
	 *				count > 1  >right<br>
	 *parameter:		SQL<br>
	 *set up name:	crazyadept<br>
	 *change time:	11/29/2004
	 */
	public ResultSet page(String sql,int span,int pagenum){
		sql=sql.toUpperCase();
		if(span==0||pagenum==0){
			return null;
		}
		int count=0,a=0,b=0;
		String table="";
		a=sql.indexOf("FROM")+4;
		b=sql.lastIndexOf("WHERE")-1;
		if(b==-2){
			b=sql.length();
		}
		if(a>b||a==b||a<=3){
		}
		sql.substring(a,b);
		try{
			getRowCount(" WHRER "+table);
			rs=con.getRs(sql);
		}catch(Exception e){
			count=-2;
			System.err.println(e.getMessage());
			e.printStackTrace();
		}finally{
			con.close();
			return rs;
		}
	}
}

⌨️ 快捷键说明

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