자바랑 mysql 이용해서 저장하는 법

mport java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MessengerA {
protected JTextField textField;
protected JTextArea textArea;
DatagramSocket socket;
DatagramPacket packet;
InetAddress address = null;
final int myPort = 5000;
final int otherPort = 6000;
public MessengerA() throws IOException{
MyFrame f = new MyFrame();
address = InetAddress.getByName("127.0.0.1");
socket = new DatagramSocket(myPort);
}
public void process(){
while (true){
try
{
byte[] buf = new byte[256];
packet = new DatagramPacket(buf,buf.length);
socket.receive(packet);
textArea.append("[abc] : "+new String(buf) + "\n");
}
catch (IOException ioException){
ioException.printStackTrace();
}
}
}
class MyFrame extends JFrame implements ActionListener{
public MyFrame(){
super("홍길동");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
textField = new JTextField(30);
textField.addActionListener(this);
textArea = new JTextArea(10,30);
textArea.setEditable(false);
add(textField, BorderLayout.PAGE_END);
add(textArea, BorderLayout.CENTER);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent evt){
String s = textField.getText();
byte[] buffer = s.getBytes();
DatagramPacket packet;
packet = new DatagramPacket(buffer, buffer.length, address, otherPort);
try{
socket.send(packet);}
catch (IOException e){
e.printStackTrace();}
textArea.append("[fgh] : "+s+"\n");
textField.selectAll();
textArea.setCaretPosition(textArea.getDocument().getLength());}
}
public static void main(String[] args) throws IOException{
MessengerA m=new MessengerA();
m.process();
}
}
-------------------------------
여기까지가 messengerA의 코드구요
messengerB 코드는 A코드와 일치하고, 이름만 messengerB입니다
대화로그를 저장해야하는데
로그를어떻게 저장해야하나요ㅜㅜ
댓글 달기