본문 바로가기
etc.

자바 컴파일 오류 unmappable character (0xED) for encoding x-windows-949 해결 과정

by 그릿er 2020. 8. 6.

 

http://programmingskills.net/archives/542 를 참고하여 해결했습니다.

 

 

 

데이터베이스 책을 따라 예제를 진행하다가 이런 오류가 떴다.

 

 

 

 

검색해보았더니 코드에 한글이 들어가 있었던 것이 문제였던 것 같다.

 

 

책을 따라 작성했던 코드는 다음과 같다.

 

import java.io.*;
import java.sql.*;

public class showMember{
	
	public static void main(String[] args) {
		
		Connection conn = null;
		Statement stmt = null;
		ResultSet rs = null;
		
		String url = "jdbc:sqlserver://localhost:1433;DatabaseName=bookstore;";
		String user = "big";
		String password = "difka03196!!";
			String query = "SELCET 회원번호,회원명,등급,주소 FROM 회원";
			
		try {
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
		}catch(ClassNotFoundException e) {
			e.printStackTrace();
		}
		
		try {
			conn=DriverManager.getConnection(url,user,password);
		}catch(SQLException e) {
			e.printStackTrace();
		}
		
		try {
			
			stmt=conn.createStatement();
			
			rs=stmt.executeQuery(query);
			
			System.out.println(" 회원번호 \t회원명 \t\t등급 \t\t주소 ");
			
			while(rs.next()) {
				System.out.print("\t"+rs.getInt("회원번호"));
				System.out.print("\t"+rs.getString("회원명"));
				System.out.print("\t"+rs.getString("등급"));
				System.out.print("\t"+rs.getString("주소"));
			}
			
			if(rs != null) rs.close();
			if(stmt != null) stmt.close();
			if(conn != null) conn.close();
		}catch(SQLException e) {
			e.printStackTrace();
		}
	}
}

 

 

 

그래서

 

javac showMember.java

 

에서

 

javac showMember.java -encoding UTF8

 

-encoding UTF8을 추가해주었더니

 

 

컴파일이 정상적으로 이루어졌다.

 

 

간단하게 해결!