赞
踩
*/
SET FOREIGN_KEY_CHECKS=0;
– Table structure for student
DROP TABLE IF EXISTS student
;
CREATE TABLE student
(
sid
int(11) NOT NULL AUTO_INCREMENT,
sname
varchar(255) NOT NULL,
sage
int(11) NOT NULL,
address
varchar(255) NOT NULL,
PRIMARY KEY (sid
)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
– Records of student
INSERT INTO student
VALUES (‘1’, ‘andi’, ‘21’, ‘21212’);
INSERT INTO student
VALUES (‘2’, ‘a’, ‘2121’, ‘2121’);
– Table structure for users
DROP TABLE IF EXISTS users
;
CREATE TABLE users
(
uid
int(11) NOT NULL AUTO_INCREMENT,
name
varchar(255) NOT NULL,
username
varchar(255) NOT NULL,
password
varchar(255) NOT NULL,
age
int(255) NOT NULL,
phone
longblob NOT NULL,
PRIMARY KEY (uid
)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
– Records of users
INSERT INTO users
VALUES (‘2’, ‘123’, ‘HBV环保局’, ‘123’, ‘33’, 0x3133333333333333333333);
INSERT INTO users
VALUES (‘3’, ‘1233’, ‘反复的’, ‘1233’, ‘12’, 0x3132333333333333333333);
INSERT INTO users
VALUES (‘4’, ‘1244’, ‘第三代’, ‘1244’, ‘12’, 0x3133333333333333333333);
INSERT INTO users
VALUES (‘5’, ‘1255’, ‘SAS’, ‘1255’, ‘33’, 0x3133333333333333333333);
切换会Android视图
注意链接数据库的地址是:jdbc:mysql://10.0.2.2:3306/test
package com.example.myapplication.utils;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class JDBCUtils {
static {
try {
Class.forName(“com.mysql.jdbc.Driver”);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public static Connection getConn() {
Connection conn = null;
try {
conn= DriverManager.getConnection(“jdbc:mysql://10.0.2.2:3306/test”,“root”,“root”);
}catch (Exception exception){
exception.printStackTrace();
}
return conn;
}
public static void close(Connection conn){
try {
conn.close();
} catch (SQLException throwables) {
throwables.printStackTrace();
}
}
}
package com.example.myapplication.entity;
public class User {
private int id;
private String name;
private String username;
private String passw
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。