您好,登錄后才能下訂單哦!
本文實例為大家分享了java聊天工具的具體制作代碼,供大家參考,具體內(nèi)容如下
首先建立一個工程,導(dǎo)入數(shù)據(jù)庫驅(qū)動
工程圖
解釋一下 entity包是 bin目錄 Message包下 和 User包下 是對象相關(guān)的操作
Message
package com.FakeQQ.entity; import java.util.Date; public class Message { //需要序列化發(fā)送,所以要繼承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
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; } }
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持億速云。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。