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

📄 userinfomodule.java

📁 文件共享虚拟社区,可以实现上传下载聊天等多种信息交互.
💻 JAVA
字号:
/*
 * Created on 2005-9-8
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package fsc.server.modules;

/**
 * @author chenhao
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

import java.sql.*;
import java.util.Date;

import fsc.models.*;
import fsc.models.exceptions.*;


public class UserInfoModule {


	private static UserInfoModule userInfoModule= new UserInfoModule();
	private static LogModule log= new LogModule("UserInfoModule.txt");
	
	public static UserInfoModel getUserInfo(String username)
	{
		Connection conn=null;
		UserInfoModel ret=null;
		try {
			conn = DatabaseModule.getConnection();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try
		{
			String sqlgetUserInfo="select username,sex,money,question,answer,email from user_info where username = '"+username+"'";
			Statement st= conn.createStatement(); // = conn.prepareCall(sqlLogin);
			
			ResultSet rs = st.executeQuery(sqlgetUserInfo);
			
			if (rs.next())
			{
				ret=new UserInfoModel();
				ret.setUserName(username);
				ret.setSex(rs.getString("sex").charAt(0));
				ret.setMoney(rs.getLong("money"));
				ret.setQuestion(rs.getString("question"));
				ret.setEmail("email");			
			}
			else	//there is no such user!!
			{
				
			}
			

			//debug
			//System.out.println("In UserInfoModule, retval is:\n"+ret.toString());
			log.log(new Date().toLocaleString()+ "\tqueryed user " + ret.getUserName()+" \n" );

			//rs.close();
			//st.close();
			//rs=null;
			st=null;
		}
		catch(SQLException sqle)
		{
			sqle.printStackTrace();
		}

		
		return ret;
	}
/*
	public static void close()
	{
		try {
			rs.close();
			st.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		rs=null;
		st=null;
	}
	*/
	
	public static void main(String[] args) {
	}
}

⌨️ 快捷键说明

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