本文实例为大家分享了java聊天工具的具*作代码,供大家参考,具体内容如下
首先建立一个工程,导入数据库驱动
工程图
解释一下 entity包是 bin目录 message包下 和 user包下 是对象相关的操作
message
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
package com.fakeqq.entity;
import java.util.date;
public class message {
//需要序列化发送,所以要继承serializable接口
private int id;
private string content;
private int sender;
private int receiver;
private date sendtime;
private date receivetime;
private int state;
private int ip;
public int getip() {
return ip;
}
public void setip( int ip) {
this .ip = ip;
}
public int getid() {
return id;
}
public void setid( int id) {
this .id = id;
}
public string getcontent() {
return content;
}
public void setcontent(string content) {
this .content = content;
}
public int getsender() {
return sender;
}
public void setsender( int sender) {
this .sender = sender;
}
public int getreceiver() {
return receiver;
}
public void setreceiver( int receiver) {
this .receiver = receiver;
}
public date getsendtime() {
return sendtime;
}
public void setsendtime(date sendtime) {
this .sendtime = sendtime;
}
public date getreceivetime() {
return receivetime;
}
public void setreceivetime(date receivetime) {
this .receivetime = receivetime;
}
public int getstate() {
return state;
}
public void setstate( int state) {
this .state = state;
}
}
|
user
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
package com.fakeqq.entity;
import java.util.date;
public class user {
//这叫实体bin
private int qqnumber;
private string qqname;
private string qqpassword;
private date registtime; //注册时间
private string sex;
private string introduce; //个人简介
private string ip;
public int getqqnumber() {
return qqnumber;
}
public void setqqnumber( int qqnumber) {
this .qqnumber = qqnumber;
}
public string getqqname() {
return qqname;
}
public void setqqname(string qqname) {
this .qqname = qqname;
}
public string getqqpassword() {
return qqpassword;
}
public void setqqpassword(string qqpassword) {
this .qqpassword = qqpassword;
}
public date getregisttime() {
return registtime;
}
public void setregisttime(date registtime) {
this .registtime = registtime;
}
public string getsex() {
return sex;
}
public void setsex(string sex) {
this .sex = sex;
}
public string getintroduce() {
return introduce;
}
public void setintroduce(string introduce) {
this .introduce = introduce;
}
public string getip() {
return ip;
}
public void setip(string ip) {
this .ip = ip;
}
}
|
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。