package com.library.dao;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.sun.corba.se.pept.transport.Connection;
import com.sun.corba.se.spi.orbutil.fsm.Guard.Result;
public class BaseDao {
//gain
protected Connection getConnection() {
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver");
conn = (Connection) DriverManager.getConnection("jdbc:mysq;://localhost:3306/mysql","root","1234");
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return conn;
}
//release
@SuppressWarnings("unused")
private void closeAll(Connection con,PreparedStatement ps,ResultSet rs) {
// TODO Auto-generated method stub
try {
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
if (con != null) {
con.close();
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}
insert into book (b_name,b_author,b_time,b_type) values ('CSS','Alice',2020-02-04,0);
insert into book (b_name,b_author,b_time,b_type) values ('JSP','Alice',2020-02-04,0);
insert into book (b_name,b_author,b_time,b_type) values ('JavaScript','Alice',2020-02-04,0);
insert into book (b_name,b_author,b_time,b_type) values ('C#','Jack',2020-02-04,0);
public class BookManage {
private int id;
private String name;
private String author;
private String time;
private int type;
public BookManage() {
}
public BookManage(String name,String author,String time,int type) {
this.name = name;
this.author = author;
this.time = time ;
this.type = type;
}
public BookManage(int id,String name,String author,String time,int type) {
this.id = id;
this.name = name;
this.author = author;
this.time = time ;
this.type = type;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
}