package com.biyeseng.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
/**
* 数据库管理类
* @author biyeseng
* @company www.biyeseng.cn
*
*/
public class DBManager {
public static final String DEFAULT_DRIVER_NAME = "com.mysql.jdbc.Driver";
public static final String DEFAULT_DB_URL = "jdbc:mysql://localhost:3306/tsgglxt?useUnicode=true&characterEncoding=UTF-8";
public static String DB_URL = null;
public static Properties prop = null;
// 获取数据连接
public Connection getConnection() {
Connection coon = null;
try {
Class.forName(DEFAULT_DRIVER_NAME);
coon = DriverManager.getConnection(DEFAULT_DB_URL, "root", "123456");
} catch (Exception e) {
e.printStackTrace();
}
return coon;
}
public static void main(String[] args) {
DBManager manager = new DBManager();
manager.getConnection();
}
public String login(String username, String pwd) {
Connection coon = getConnection();
ResultSet rs = null;
PreparedStatement pstmt = null;
try {
pstmt = coon
.prepareStatement("select * from admin where userName='"
+ username + "' and userPw='" + pwd + "'");
rs = pstmt.executeQuery();
while (rs.next()) {
return rs.getString("type");
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (pstmt != null)
pstmt.close();
if (coon != null)
coon.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
public String loginYH(String username, String pwd) {
Connection coon = getConnection();
ResultSet rs = null;
PreparedStatement pstmt = null;
try {
pstmt = coon.prepareStatement("select * from hui where card='"
+ username + "' and pass='" + pwd + "'");
rs = pstmt.executeQuery();
while (rs.next()) {
return rs.getString("name") + ":" + rs.getString("state");
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (pstmt != null)
pstmt.close();
if (coon != null)
coon.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
public boolean hasId(String goodsid) {
Connection coon = getConnection();
ResultSet rs = null;
PreparedStatement pstmt = null;
try {
pstmt = coon.prepareStatement("select * from kucun where goodsid='"
+ goodsid + "'");
rs = pstmt.executeQuery();
while (rs.next()) {
return true;
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (pstmt != null)
pstmt.close();
if (coon != null)
coon.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return false;
}
public static String TextToHtml(String sourcestr) {
int strlen;
String restring = "", destr = "";
strlen = sourcestr.length();
for (int i = 0; i < strlen; i++) {
char ch = sourcestr.charAt(i);
switch (ch) {
case '<':
destr = "<";
break;
case '>':
destr = ">";
break;
case '\"':
destr = "\"";
break;
case '&':
destr = "&";
break;
case 13:
destr = "<br>";
break;
case 32:
destr = " ";
break;
default:
destr = "" + ch;
break;
}
restring = restring + destr;
}
return "" + restring;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
jsp+Servlet利用mvc模式写的一个图书馆管理系统(源码带sql文件)
共432个文件
png:138个
gif:111个
js:62个
4星 · 超过85%的资源 需积分: 10 166 下载量 46 浏览量
2017-01-13
14:35:02
上传
评论 14
收藏 2.81MB ZIP 举报
温馨提示
这是一个对学生学习开发java web的源码(代码编写不易,1分资源不过分),里面是jsp+Servlet利用mvc模式写的一个后台图书管理系统,里面有数据库sql,直接添加就可以。
资源推荐
资源详情
资源评论
收起资源包目录
jsp+Servlet利用mvc模式写的一个图书馆管理系统(源码带sql文件) (432个子文件)
.classpath 2KB
org.eclipse.wst.common.component 549B
org.eclipse.wst.jsdt.ui.superType.container 49B
easyui.css 26KB
easyui.css 25KB
style.css 20KB
list.css 7KB
sophia_style.css 7KB
common.css 5KB
datepicker.css 5KB
datepicker.css 5KB
style.css 5KB
datagrid.css 5KB
datagrid.css 5KB
tabs.css 3KB
tabs.css 3KB
calendar.css 3KB
calendar.css 3KB
tree.css 2KB
tree.css 2KB
layout.css 2KB
layout.css 2KB
select.css 2KB
panel.css 2KB
panel.css 2KB
linkbutton.css 1KB
linkbutton.css 1KB
window.css 1KB
window.css 1KB
menu.css 1KB
menu.css 1KB
icon.css 1KB
pagination.css 933B
pagination.css 933B
combobox.css 872B
combobox.css 872B
splitbutton.css 733B
splitbutton.css 733B
spinner.css 732B
spinner.css 732B
combo.css 667B
combo.css 667B
combotree.css 666B
combotree.css 666B
validatebox.css 634B
validatebox.css 634B
messager.css 610B
messager.css 610B
dialog.css 422B
dialog.css 422B
datebox.css 421B
accordion.css 421B
datebox.css 421B
accordion.css 421B
menubutton.css 392B
menubutton.css 392B
WdatePicker.css 158B
button_span_bg.gif 2KB
button_span_bg.gif 2KB
tree_loading.gif 2KB
panel_loading.gif 2KB
pagination_loading.gif 2KB
tree_loading.gif 2KB
panel_loading.gif 2KB
pagination_loading.gif 2KB
img.gif 2KB
messager_error.gif 2KB
messager_error.gif 2KB
messager_question.gif 2KB
messager_question.gif 2KB
messager_info.gif 2KB
messager_info.gif 2KB
img.gif 2KB
messager_warning.gif 1KB
messager_warning.gif 1KB
button_a_bg.gif 1KB
button_a_bg.gif 1KB
edit.gif 1KB
tree_arrows.gif 1KB
datePicker.gif 1KB
tree_arrows.gif 1KB
add.gif 1KB
view.gif 1KB
audit.gif 1KB
tree_folder_open.gif 956B
tree_folder_open.gif 956B
tree_folder.gif 952B
tree_folder.gif 952B
pagination_first.gif 925B
pagination_first.gif 925B
pagination_last.gif 923B
pagination_last.gif 923B
tabs_close.gif 896B
tabs_close.gif 896B
pagination_prev.gif 879B
pagination_prev.gif 879B
pagination_next.gif 875B
pagination_next.gif 875B
menu.gif 834B
menu.gif 834B
共 432 条
- 1
- 2
- 3
- 4
- 5
资源评论
- qq_414347672017-12-29挺有用的啊
- 祈月月月2018-04-18来学习一下
- qq_391352532018-12-25挺好用的啊
- 「已注销」2018-06-11来学习学习
wx_jb
- 粉丝: 2
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功