JDBC
JDBC
写在前面:
创建普通的Maven项目(无web)
2、在pom.xml中导包
1 <dependencies> 2 <dependency> 3 <groupId>mysql</groupId> 4 <artifactId>mysql-connector-java</artifactId> 5 <version>5.1.47</version> 6 </dependency> 7 </dependencies>
1、创建数据库
1 CREATE TABLE users( 2 id INT PRIMARY KEY, 3 `name` VARCHAR(40), 4 `PASSWORD` varchar(40), 5 email VARCHAR(60), 6 birthday DATE 7 ); 8 9 INSERT INTO users(id,`name`,`password`,email,birthday) 10 VALUES(1,'张三','1','1@qq.com','2000-01-01'); 11 INSERT INTO users(id,`name`,`password`,email,birthday) 12 VALUES(2,'李四','2','2@qq.com','2000-02-02'); 13 INSERT INTO users(id,`name`,`password`,email,birthday) 14 VALUES(3,'王五','3','3@qq.com','2000-03-03'); 15 16 SELECT * FROM users;
3、连数据库
具体在7中的:JDBC的工具类