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

📄 row.java

📁 重点不是信息管理系统
💻 JAVA
字号:
package com.yijia_ctgu.DB;

import java.sql.SQLException;

import com.yijia_ctgu.exception.NotQueryException;
/**
 * 
 * @author yijia
 *
 */
public class Row {
	String tableName;
	String mainPropertyValue;
	String mainPropertyName;
	DBExcute dbExcute=new DBExcute();
	
    Row(String tableName,String mainPropertyName,String mainPropertyValue){
	  this.mainPropertyName=mainPropertyName;
	  this.mainPropertyValue=mainPropertyValue;
	  this.tableName=tableName;
   }
    public void set(String propertyName,String propertyValue) throws SQLException{
    	String sql="update "+tableName+" set "+propertyName+"='"+propertyValue+"' where "+mainPropertyName+"='"+mainPropertyValue+"' ";
    	try {
    		dbExcute.update(sql);
    	} catch (SQLException ex) {
    		throw ex;
    	}
    }
    public void set(String property[][]) throws SQLException{
    	String sql="update "+tableName+" set ";
    	int i;
    	for( i=0;i<(property.length-1);i++){
    		sql+=property[i][0]+"='"+property[i][1]+"',";
    		System.out.println(property[i][0]+""+property[i][1]);
    	}
    	sql+=property[i][0]+"='"+property[i][1]+"' where "+mainPropertyName+"='"+mainPropertyValue+"' ";
    	System.out.println(property[i][0]+""+property[i][1]);
    	try {
    		dbExcute.update(sql);
    	} catch (SQLException ex) {
    		throw ex;
    	}
    }
    public String get(String propertyName) throws SQLException, NotQueryException{
    	String sql="select "+propertyName+" from "+tableName+" where "+mainPropertyName+"='"+mainPropertyValue+"' ";
 	   try{
 		   String str=dbExcute.queryString(sql);
 		   return str;
 	   }catch(NotQueryException ex){
 		throw ex;
 		}catch(SQLException ex){
 			throw ex;
 		}
    }
    /**
     * 
     * test the function of my DBtools
     */
    public static void main(String []dfd){
		try {
			try {
				System.out.println(DB.getTable("user").getRowData("admin").get("usertype"));
			} catch (NotQueryException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

    }
}

⌨️ 快捷键说明

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