package ch27;
import java.security.MessageDigest;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class personaljob {
private Connection conn = null;
public String error = null; //错误信息
private String username = null; //登录用户名
private String password = null; //登录密码
//初始化,进行数据库驱动的加载和数据库的连接
public boolean init(String mysqlDriver, String mysqlUrl, String mysqlUser,
String mysqlPsw) {
try {
Class.forName(mysqlDriver);
this.conn = DriverManager.getConnection(mysqlUrl, mysqlUser,
mysqlPsw);
return true;
} catch (Exception e) {
this.error = e.toString();
return false;
}
}
//返回中文字符
public String getStr(String str) {
try {
String temp_p = str;
byte[] temp_t = temp_p.getBytes("ISO8859-1");
String temp = new String(temp_t);
return temp;
} catch (Exception e) {
return null;
}
}
//HTML特殊字符转换
public String HtmlSpecialChars(String str) {
if (str == null || str.equals("")) {
return str;
}
StringBuffer temp = new StringBuffer();
int i = 0;
while (i < str.length()) {
//将\n转换成<br>
if (str.charAt(i) == '\n') {
temp = temp.append("<br>");
}
//将空格转换成
else if (str.charAt(i) == ' ') {
temp = temp.append(" ");
}
//将<转换成<
else if (str.charAt(i) == '<') {
temp = temp.append("<");
}
//将>转换成>
else if (str.charAt(i) == '>') {
temp = temp.append(">");
}
else {
temp = temp.append(str.substring(i, i + 1));
}
i++;
}
String okstring = temp.toString();
return okstring;
}
//MD5加密
public String md5(String x) {
try {
MessageDigest m = MessageDigest.getInstance("MD5");
m.update(x.getBytes("UTF8"));
byte s[] = m.digest();
String result = "";
for (int i = 0; i < s.length; i++) {
result += Integer.toHexString((0x000000FF & s[i]) | 0xFFFFFF00)
.substring(6);
}
return result;
} catch (Exception e) {
this.error = e.toString();
return null;
}
}
//设置登录用户名
public void setUsername(String user) {
this.username = user;
}
//设置密码 已经加密
public void setPasswrod(String psw) {
this.password = psw;
}
public boolean logcheck() {
if (this.username == null || this.password == null) {
return false;
} else {
int i = 0;
try {
String query = "select * from `pjm_user` where `username`='"
+ this.username + "' and `password`='" + this.password
+ "'";
System.out.println(query);
PreparedStatement ps = this.conn.prepareStatement(query);
ResultSet res = ps.executeQuery();
while (res.next())
i++;
res.close();
ps.close();
if (i != 1)
return false;
else
return true;
} catch (Exception e) {
this.error = e.toString();
return false;
}
}
}
public ResultSet getJobsSimply() {
String belongto = this.username;
if (belongto == null || belongto.equals(""))
return null;
String query = "select `id`,`cop_name`,`job_name`,`job_addr`,`job_get`,`job_sta`,`job_end`,`job_grad`,`job_lang`,`send`,`re` from `pjm_jobs` where `belongto`='"
+ belongto + "' order by `id` desc";
ResultSet res = null;
try {
PreparedStatement ps = this.conn.prepareStatement(query);
res = ps.executeQuery();
return res;
} catch (Exception e) {
this.error = e.toString();
return null;
}
}
public ResultSet getCopInfo(String id) {
if (id == null || this.username == null || id == ""
|| this.username == "")
return null;
String query = "select `cop_name`,`cop_mann`,`cop_cont`,"
+ "`cop_tel`,`cop_mail`,`cop_fax`,`cop_addr`,`cop_zip`,"
+ "`cop_www`,`cop_desc` from `pjm_jobs` where `id`=" + id
+ " and `belongto`='" + this.username + "'";
ResultSet res = null;
try {
PreparedStatement ps = this.conn.prepareStatement(query);
res = ps.executeQuery();
return res;
} catch (Exception e) {
this.error = e.toString();
return null;
}
}
public ResultSet getSearchJob(String cop_name, String cop_addr,
String job_name, String job_addr, String job_get) {
String sql = "select * from `pjm_jobs` where 1=1 ";
if (cop_name != null && !"".equals(cop_name))
sql += "and `cop_name` like '%" + cop_name + "%'";
if (cop_addr != null && !"".equals(cop_addr))
sql += "and `cop_addr` like '%" + cop_addr + "%'";
if (job_name != null && !"".equals(job_name))
sql += "and `job_name` like '%" + job_name + "%'";
if (job_addr != null && !"".equals(job_addr))
sql += "and `job_addr` like '%" + job_addr + "%'";
if (job_get != null && !"".equals(job_get))
sql += "and `job_get` like '%" + job_get + "%'";
System.out.println("sql=" + sql);
ResultSet res = null;
try {
PreparedStatement ps = this.conn.prepareStatement(sql);
res = ps.executeQuery();
return res;
} catch (Exception e) {
this.error = e.toString();
return null;
}
}
public ResultSet getJobInfo(String id) {
if (id == null || this.username == null || id == ""
|| this.username == "")
return null;
String query = "select `job_name`,`job_mann`,`job_addr`,`job_num`,`job_get`,`job_sta`,`job_end`,`job_grad`,`job_age1`,`job_age2`,`job_expe`,`job_lang`,`job_odem`,`job_oget` from `pjm_jobs` where `id`="
+ id + " and `belongto`='" + this.username + "'";
ResultSet res = null;
try {
PreparedStatement ps = this.conn.prepareStatement(query);
res = ps.executeQuery();
return res;
} catch (Exception e) {
this.error = e.toString();
return null;
}
}
public boolean addJob(String cop_name, String cop_mann, String cop_cont,
String cop_tel, String cop_mail, String cop_fax, String cop_addr,
String cop_zip, String cop_www, String cop_desc, String job_name,
String job_mann, String job_addr, String job_num, String job_get,
String job_sta, String job_end, String job_age1, String job_age2,
String job_grad, String job_lang, String job_expe, String job_oget,
String job_odem) {
try {
PreparedStatement ps = this.conn
.prepareStatement("INSERT INTO `pjm_jobs` VALUES ('',?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,'',0,'')");
ps.setString(1, this.us
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
job.rar (52个子文件)
job
login.jsp 1KB
css
bar.js 468B
style.css 2KB
.project 384B
WEB-INF
src
ch27
personaljob.java 20KB
personaljobdata.java 483B
lib
classes
ch27
personaljob.class 14KB
personaljobdata.class 1KB
index.jsp 2KB
addnewjobdo.jsp 3KB
ima
resume_step_left_full.gif 117B
bottom.gif 2KB
arrowwhite.gif 51B
nextto.gif 123B
header_bg.gif 307B
bottom_bg.gif 49B
top_bg.gif 175B
resume_preview_tag_right.gif 107B
delete.gif 387B
resume_preview_tag_left.gif 148B
arrowyellow.gif 51B
header_arrows.gif 2KB
indexpagebg.gif 3KB
edit.gif 380B
resume_preview_line_orange.gif 407B
resume_step_right_empty.gif 143B
divider.gif 105B
arrowblue.gif 51B
resume_preview_tag.gif 67B
Thumbs.db 32KB
resume_step_right_full.gif 119B
resume_step_left_empty.gif 104B
info_bg.gif 123B
pop_bg.gif 979B
resume_preview_tag_line.gif 122B
shadow.gif 255B
add.jsp 6KB
list.jsp 10KB
sendre.jsp 6KB
.classpath 1KB
action.jsp 9KB
logout.jsp 315B
lib
config.jsp 368B
sendre_send.htm 3KB
detail_cop.htm 3KB
add.htm 9KB
detail_job.htm 3KB
sendre_re.htm 3KB
edit.htm 8KB
resume_view.jsp 7KB
addnewjob.jsp 15KB
detail.jsp 5KB
共 52 条
- 1
资源评论
- youyou3328529592012-11-30关于公jsp编写系统很有帮助
- Hmz31922018-01-07真的是太垃圾了
- GUIGUZIAOI2014-04-18谢谢前辈的工作,JSP运用的很好,
- etracer2014-05-09感觉太简单了,不过还算有帮助
单车程序员
- 粉丝: 9
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功