import java.sql.DriverManager;
import java.sql.SQLException;
import com.sun.corba.se.pept.transport.Connection;
public class DBHelper{
private static final String driver = "com.mysql.jdbc.Driver"; //数据库驱动
//连接数据库的URL地址
private static final String url = "jdbc:mysql://localhost:3306/Library?useUnicode=true & characterEncoding=UTF-8";
private static final String username = "root";//数据库的用户名
private static final String password = "199702110"; // 数据库密码
private static Connection conn=null;//(导入类java.sql下的)
//静态代码块负责加载驱动
static{
try{
Class.forName(driver);
}
catch(Exception ex){
ex.printStackTrace();
}
}
//单例模式返回数据库连接对象
public static Connection getConnection() throws Exception{
if(conn==null){
conn = (Connection) DriverManager.getConnection(url,username,password);
return conn;
}
return conn;
}
public static void main(String[] args) throws Exception{
try{
Connection conn = DBHelper.getConnection();
if(conn!=null){
System.out.println("连接成功");
}else{
}
}catch(SQLException e){
System.out.println("链接数据库的过程中出现SQL异常");}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
jsp图书管理系统.zip
共72个文件
jpg:40个
jsp:14个
xml:2个
需积分: 0 1 下载量 197 浏览量
2021-12-30
13:36:08
上传
评论 1
收藏 2.25MB ZIP 举报
温馨提示
java实现的图书管理系统,带有数据库
资源推荐
资源详情
资源评论
收起资源包目录
jsp大作业图书管理系统.zip (72个子文件)
图书管理系统
11.JPG 31KB
15.JPG 25KB
12.JPG 29KB
10.JPG 30KB
30.JPG 49KB
40.JPG 49KB
31.JPG 29KB
8.JPG 30KB
Library
.project 1KB
src
test.java 28B
DBHelper.java 1KB
WebRoot
catalogue.jsp 5KB
WEB-INF
classes
test.class 237B
DBHelper.class 2KB
lib
mysql-connector-java-5.1.7-bin.jar 693KB
web.xml 569B
searchBookAdvancedStep2.jsp 2KB
searchBookBasicStep2.jsp 1KB
index.jsp 829B
searchReaderRecordStep2.jsp 2KB
orderBook.jsp 5KB
displayBookInfo.jsp 3KB
index.htm 4KB
META-INF
MANIFEST.MF 39B
destroyCard.jsp 2KB
borrowBook.jsp 3KB
searchBookBasic.jsp 509B
applyCard.jsp 4KB
searchBookAdvanced.jsp 3KB
returnBook.jsp 3KB
searchReaderRecord.jsp 872B
style.css 2KB
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.common.project.facet.core.xml 398B
org.eclipse.jdt.core.prefs 364B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.component 480B
.jsdtscope 564B
.classpath 1KB
39.JPG 46KB
28.JPG 31KB
38.JPG 54KB
3.JPG 45KB
5.JPG 62KB
7.JPG 58KB
24.JPG 28KB
26.JPG 21KB
13.JPG 30KB
22.JPG 20KB
21.JPG 30KB
9.JPG 30KB
1.JPG 57KB
6.JPG 62KB
18.JPG 49KB
2.JPG 46KB
27.JPG 58KB
32.JPG 34KB
33.JPG 67KB
17.JPG 25KB
16.JPG 21KB
20.JPG 26KB
4.JPG 64KB
36.JPG 43KB
Library.zip 692KB
23.JPG 25KB
29.JPG 33KB
34.JPG 41KB
35.JPG 41KB
14.JPG 25KB
37.JPG 44KB
19.JPG 32KB
25.JPG 39KB
共 72 条
- 1
资源评论
Faith_xzc
- 粉丝: 2w+
- 资源: 24
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功