package edu.chat;
import java.net.ServerSocket;
import java.net.Socket;
import edu.chat.way.Receiver;
import edu.chat.way.Sender;
public class ChatTcpserver { // 서버 = 기다리는 쪽 (내부적으로 계쏙 폼 돌리고있음)
public static void main(String[] args) {
ServerSocket serverSocket = null;// 서버소켓을 가지는 쪽이 서버 구축 하는 것
Socket socket = null;
try {
//포트번호 = 프로그램번호
serverSocket = new ServerSocket(8888); //포트번호 지정
System.out.println("서버가 준비되었습니다.");
socket = serverSocket.accept(); // 이 함수를 쓰기 위해 9번 줄 ServerSocket을 선언
//System.out.println(" 연결 되었습니다."+socket.getInetAddress().getHostName());
Sender sender = new Sender(socket);
Receiver receiver = new Receiver(socket);
sender.start();
receiver.start();
} catch(Exception e) {
e.printStackTrace();
}
}
}
package edu.chat;
import java.net.ServerSocket;
import java.net.Socket;
public class ChatTcpClient {
public static void main(String[] args) {
String serverIP = "127.0.0.1";
Socket socket = null;
try {
socket = new Socket(serverIP, 8888); // 아이피주소로 8888을 커넥션 ~
System.out.println("서버에 연결되었습니다.");
} catch(Exception e) {
e.printStackTrace();
}
}
}
package edu.chat.way;
import java.io.DataInputStream;
import java.net.Socket;
public class Receiver extends Thread {
private Socket socket;
private DataInputStream in;
public Receiver(Socket socket) {
this.socket = socket;
try { //보조스트림
in = new DataInputStream(socket.getInputStream());
} catch(Exception e) {
}
}
public void run() {
while(in != null) {
try {
System.out.println(in.readUTF());
} catch (Exception e) {
}
}
}
}
package edu.chat.way;
import java.io.DataOutputStream;
import java.net.Socket;
import java.util.Scanner;
public class Sender extends Thread {
private Socket socket;
private DataOutputStream out;
private String name;
public Sender(Socket socket) {
this.socket = socket;
try {//보조스트림
out = new DataOutputStream(socket.getOutputStream());
name = "["+socket.getInetAddress()+":"+socket.getPort()+"]";
} catch(Exception e) {
}
}
public void run() {
Scanner scanner = new Scanner(System.in);
while(out != null) {
try {
out.writeUTF(name + scanner.nextLine());
} catch (Exception e) {
}
}
}
}
데이터베이스(Database)의 약어로, 체계적으로 구성된 데이터의 집합
데이터베이스 관리 시스템(Database Management System)의 약어로, 데이터베이스를 생성, 조작, 관리하기 위한 소프트웨어
Oracle, MySQL, SQL Server, PostgreSQL, MongoDB 등
-부서 번호(DEPTNO)가 20인 사원에 관한 정보만 출력
select * from emp where deptno = 20;
-1982년 1월 1일 이후에 입사한 사원을 출력하는 쿼리문
select * from emp where hiredate between '82/01/01' and '82/12/31';
-desc 명령어에 대하여 설명하시오.
데이터베이스에서 테이블의 구조와 속성을 조회하는 명령어
-커미션(COMM)이 300 혹은 500 혹은 1400이 아닌 사원
select * from emp where comm not in(300,500,1400);
-커미션(COMM)이 300 혹은 500 혹은 1400인 사원 검색
select * from emp where comm in(300, 500, 1400);
-급여가 2000 미만이거나 3000 초과인 사원을 검색하는 쿼리문
select * from emp where sal not between 2000 and 3000;
-급여가 2000~3000 사이의 사원을 검색하는 쿼리문
select * from emp where sal between 2000 and 3000;