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

📄 usercoinselectbean.java

📁 一个简单的JavaSe的入门
💻 JAVA
字号:
package com.buy.bean.coin;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.buy.bean.comm.database.DBConnect;
public class UsercoinSelectBean {
	public String selectUsercoin(String ID,int i){
		String condition;
		if(i==0){
			condition = "select coin from user where id = '"+ID+"'";
		}else if(i==1){
			condition = "select consume from user where id = '"+ID+"'";
		}else if(i==2){
			condition = "select consume + coin from user where id = '"+ID+"'";
		}else if(i==3){
			condition = "select name from user where id = '"+ID+"'";
		}else{
			condition = "select type from user where id = '"+ID+"'";
		}
		ResultSet rs = null;
		Statement sql = null;		
		String str = new String();
		try {
			Connection conn = DBConnect.getConnection();
			sql = conn.createStatement();
			rs = sql.executeQuery(condition);					
			while (rs.next()) {				
				str = rs.getString(1);
			}	
			rs.close();
			sql.close();
			conn.close();
		} catch (SQLException ex) {
			System.out.println("TradeDB SQLException: " + ex.getMessage());
			return new String("can not select");
		}
		return str;
	}
}

⌨️ 快捷键说明

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