ajaxdao.java
来自「这是本人最初练习ajax时的小程序,是用JSP写的」· Java 代码 · 共 47 行
JAVA
47 行
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 + =
减小字号Ctrl + -
显示快捷键?