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

📄 persondaoimpl.java

📁 DAO实现留言板
💻 JAVA
字号:
package com.commit.dao.daoimpl;

import com.commit.dao.dao.*;
import com.commit.dao.vo.*;
import com.commit.dao.dbc.*;
import java.sql.*;
import java.util.*;

public class PersonDAOImpl implements PersonDAO
{
	public boolean isRegedit(PersonVo pv)
	{
		boolean flag = false ;
		//regedit
		PreparedStatement pstmt = null ;
		String sql = null ;
		DataBaseConnection dbc = null ;
		//connect to database
		dbc = new DataBaseConnection() ;
		//init sql
		sql = "insert into userinfo (name,password,email) values (?,?,?)" ;
		try
		{
			pstmt = dbc.getConnection().prepareStatement(sql) ;
			pstmt.setString(1, pv.getName()) ;
			pstmt.setString(2, pv.getPassword()) ;
			pstmt.setString(3, pv.getEmail()) ;
			pstmt.executeUpdate() ;
			
			pstmt.close() ;
			flag = true ;
		}
		catch(Exception e)
		{
			//System.out.println("regedit java") ;
		}
		finally
		{
			dbc.close();
		}
		return flag ;
	}
	
	public boolean isLogin(PersonVo pv)
	{
		boolean flag = false ;
		//login
		String sql = null ;
		PreparedStatement pstmt = null ;
		ResultSet rs = null ;
		DataBaseConnection dbc = null ;
		dbc = new DataBaseConnection() ;
		sql = "select * from userinfo where name=? and password=?" ;
		try
		{
			pstmt = dbc.getConnection().prepareStatement(sql) ;
			pstmt.setString(1,pv.getName()) ;
			pstmt.setString(2, pv.getPassword()) ;
			rs = pstmt.executeQuery() ;
			while(rs.next())
			{
				flag = true ;
			}
			rs.close() ;
			pstmt.close() ;
		}
		catch(Exception e)
		{}
		finally
		{
			dbc.close();
		}		
		return flag ;
	}
}

⌨️ 快捷键说明

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