Tomcat 5.5.20
MySQL 5.0.xx community server
jsp
아주 쇼를 하는구나...
Tomcat의 JNDI 방식으로 Connection Pool을 사용할려구 하다가 MySQL charset 땜시 아주 미칠뻔 했다.
결국은 소 뒷걸음 치다가 쥐잡는 식으로 해결하긴 했다.
일단 MySQL의 환경은 다음과 같다.
show variables like '%c%'
아래에서 "character_set_database"이 "latin1" 이었다.
show variables like '%c%' (101 Records)
| Variable_name | Value |
|---|---|
| auto_increment_increment | 1 |
| auto_increment_offset | 1 |
| automatic_sp_privileges | ON |
| back_log | 50 |
| binlog_cache_size | 32768 |
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | euckr |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | c:\mysql\share\charsets\ |
| collation_connection | latin1_swedish_ci |
| collation_database | euckr_korean_ci |
| collation_server | latin1_swedish_ci |
| completion_type | 0 |
| concurrent_insert | 1 |
| connect_timeout | 5 |
| div_precision_increment | 4 |
| engine_condition_pushdown | OFF |
| group_concat_max_len | 1024 |
| have_archive | YES |
| have_blackhole_engine | NO |
| have_compress | YES |
| have_crypt | NO |
| have_csv | NO |
| have_dynamic_loading | YES |
| have_ndbcluster | NO |
| have_query_cache | YES |
| init_connect | |
| innodb_autoextend_increment | 8 |
| innodb_checksums | ON |
| innodb_commit_concurrency | 0 |
| innodb_concurrency_tickets | 500 |
| innodb_flush_log_at_trx_commit | 1 |
| innodb_force_recovery | 0 |
| innodb_lock_wait_timeout | 50 |
| innodb_locks_unsafe_for_binlog | OFF |
| innodb_log_arch_dir | |
| innodb_log_archive | OFF |
| innodb_max_dirty_pages_pct | 90 |
| innodb_sync_spin_loops | 20 |
| innodb_table_locks | ON |
| innodb_thread_concurrency | 8 |
| interactive_timeout | 28800 |
| key_cache_age_threshold | 300 |
| key_cache_block_size | 1024 |
| key_cache_division_limit | 100 |
| lc_time_names | en_US |
| license | GPL |
| local_infile | ON |
| log_bin_trust_function_creators | OFF |
| lower_case_file_system | ON |
| lower_case_table_names | 1 |
| max_allowed_packet | 1048576 |
| max_binlog_cache_size | 4294967295 |
| max_connect_errors | 10 |
| max_connections | 100 |
| max_error_count | 64 |
| max_prepared_stmt_count | 16382 |
| max_sp_recursion_depth | 0 |
| max_user_connections | 0 |
| max_write_lock_count | 4294967295 |
| multi_range_count | 256 |
| myisam_recover_options | OFF |
| net_retry_count | 10 |
| optimizer_search_depth | 62 |
| prepared_stmt_count | 0 |
| protocol_version | 10 |
| query_alloc_block_size | 8192 |
| query_cache_limit | 1048576 |
| query_cache_min_res_unit | 4096 |
| query_cache_size | 0 |
| query_cache_type | ON |
| query_cache_wlock_invalidate | OFF |
| query_prealloc_size | 8192 |
| range_alloc_block_size | 2048 |
| relay_log_space_limit | 0 |
| rpl_recovery_rank | 0 |
| secure_auth | OFF |
| skip_external_locking | ON |
| slave_compressed_protocol | OFF |
| slave_transaction_retries | 10 |
| slow_launch_time | 2 |
| sql_big_selects | ON |
| ssl_ca | |
| ssl_capath | |
| ssl_cert | |
| ssl_cipher | |
| sync_binlog | 0 |
| sync_frm | ON |
| table_cache | 64 |
| table_lock_wait_timeout | 50 |
| thread_cache_size | 0 |
| thread_stack | 196608 |
| transaction_alloc_block_size | 8192 |
| transaction_prealloc_size | 4096 |
| version_comment | MySQL Community Edition (GPL) |
| version_compile_machine | ia32 |
| version_compile_os | Win32 |
generated 2008-07-18 오후 4:13:18 by MySQL-Front 2.5
데이터베이스를 생성하고 다음의 명령으로 charset 변경
ALTER DATABASE MY_DATABASE DEFAULT CHARACTER SET euckr;
그 다음 mysql로 데이터를 백업받아서 생긴 sql 파일의 제일 상단에 다음의 한줄을 추가함
set names euckr;
그리고 커맨드에서 다음의 문장을 실행
mysql -u root -pxxxxxxx my_database < C:\my_database.sql
tomcat의 server.xml에서 context아래에 Resource를 정의한다.
<Resource name="jdbc/flexmate" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="root" password="" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/my_database?autoReconnect=true?&useUnicode=true&characterEncoding=euckr"/>
끝...
웹에서 조회할 때는 MySQL Front에서 한글이 정상적으로 표시되었다.
하지만 euckr로 변경하고 나니 MySQL Front에서 한글이 전부 ?로 표시된다...
젠장...
아 삽질의 끝은 어디인가?



::: 사람과 사람의 교감! 人터넷의 첫 시작! 댓글을 달아주세요! :::