部分数据库
CREATE TABLE tb_bookinfo
(
ISBN
varchar(20) DEFAULT NULL,
typeid
varchar(20) DEFAULT NULL,
writer
varchar(20) DEFAULT NULL,
translator
varchar(20) DEFAULT NULL,
publisher
varchar(20) DEFAULT NULL,
date
datetime DEFAULT NULL,
price
double DEFAULT NULL,
bookname
varchar(40) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*Data for the table tb_bookinfo
*/
insert into tb_bookinfo
(ISBN
,typeid
,writer
,translator
,publisher
,date
,price
,bookname
) values (‘1111111111111’,‘2’,‘出版人’,‘哈哈’,’***出版社’,‘2013-04-24 00:00:00’,20,‘java开发’);
/*Table structure for table tb_booktype
*/
DROP TABLE IF EXISTS tb_booktype
;
CREATE TABLE tb_booktype
(
id
int(11) NOT NULL AUTO_INCREMENT,
typeName
varchar(20) DEFAULT NULL,
days
varchar(20) DEFAULT NULL,
fk
varchar(20) DEFAULT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
public class Dao {
protected static String dbClassName = "com.mysql.jdbc.Driver";
protected static String dbUrl = "jdbc:mysql://localhost:3306/db_library";
protected static String dbUser = "root";
protected static String dbPwd = "1234";
protected static String second = null;
private static Connection conn = null;
private Dao() {
try {
if (conn == null) {
Class.forName(dbClassName).newInstance();
conn = DriverManager.getConnection(dbUrl, dbUser, dbPwd);
}
else
return;
} catch (Exception ee) {
ee.printStackTrace();
}
}
private static ResultSet executeQuery(String sql) {
try {
if(conn==null)
new Dao();
return conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE).executeQuery(sql);
} catch (SQLException e) {
e.printStackTrace();
return null;
} finally {
}
}