jdbc连接Sqlite,MYsql 的编码修改

来源:互联网 发布:北京网络派出所 编辑:程序博客网 时间:2024/06/07 14:49

javaEE can use many heavy weight DBS such as Orach,DB2,sqlServer,Mysql.But Sqlite can also be with it. Some key settings are here:

 

 1> Class.forName("org.sqlite.JDBC");

 

 2> Connection cn = DriverManager.getConnection("jdbc:sqlite:filepath[where your .db stored");


Modify Mysql's character encoding:

This is what your command shows when you first input the command ( Mysql 5.5):

  mysql> show variables like 'character%';

Then the results showing:

+--------------------------+---------------------------------+
| Variable_name            | Value                           |
+--------------------------+---------------------------------+
| character_set_client     | gbk                             |
| character_set_connection | gbk                             |
| character_set_database   | latin1                          |
| character_set_filesystem | binary                          |
| character_set_results    | gbk                             |
| character_set_server     | latin1                          |
| character_set_system     | utf8                            |
| character_sets_dir       |/usr/share/mysql/charsets/ |

+--------------------------+---------------------------------+

 so if you want to raise the characterSet , you can modify it in themysql.in file(rather than view it as the commands) something like this:


1. First, modify  the client settings:

default-character-set=utf8   // There must be utf8 rather than utf-8;

2. Second, modify the server:

character-set-server = utf8

   So if you had done those above, all your character sets  must be the utf8. But you will find the tribulance in the 

command if you use the Chinese. This is because the XP cmd use the character "gbk" as default, hence it do show

messy code. But don't worry, run the command beneathe every time when you are using Chinese in the command,

it would be ok。

 mysql> set character_set_results='gbk';