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

📄 ajaxdao.java

📁 这是本人最初练习ajax时的小程序,是用JSP写的
💻 JAVA
字号:
package com.chinasoft.db;

import java.sql.*;

public class AjaxDAO {
    private Connection conn=null;
//    private final static String queryblog="select myblog from ajaxtable where username=? and password=?";
    private final static String queryaccount="select * from ajaxtable where username=? and password=?";
 //   private final static String querylink="select mylink from ajaxtable where username=? and password=?";
    protected void getConn(){
    	try {
			this.conn=DataSourceFactory.getDataSource().getConnection();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }
    protected void freeConn(){
    	try {
			this.conn.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }
    public AjaxDTO LoginCheck(String user,String psw){
    	getConn();
    	AjaxDTO ajaxdto=new AjaxDTO();
    	try {
			PreparedStatement psmt=conn.prepareStatement(queryaccount);
			psmt.setString(1,user);
			psmt.setString(2,psw);
			ResultSet rs=psmt.executeQuery();
			if(rs.next()){
				ajaxdto.setMyblog(rs.getString("myblog"));
				ajaxdto.setMylink(rs.getString("mylink"));
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			freeConn();
		}
		 return ajaxdto;  
    } 
}

⌨️ 快捷键说明

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