Java ¶ÁÈ¡ MySQL ÖÐÎÄ ÂÒÂë
Java ¶ÁÈ¡ MySQL ÖÐÎÄ ÂÒÂë
³¡¾°:Java,eclipse£¬¶ÁÈ¡MySQLÊý¾Ý¿â£¬MySQL±àÂëΪutf-8
ÎÊÌ⣺¶Á³öÀ´µÄÖÐÎÄÔÚeclipseµÄÊä³ö´°¿ÚÖÐÏÔʾΪÂÒÂë
´íÎóµÄд·¨
1
System.out.print(new String( rs.getString("bib_author").getBytes("utf-8"),"GBK" ));
2
System.out.print( rs.getString("bib_author"));
JavaÖÐͳһʹÓÃUnicode±àÂë¡£
ÕýÈ·µÄд·¨£º
System.out.print(new String (rs.getBytes("bib_author"),"utf-8") + " ");
Èç»®Ïß¼Ó´Ö²¿·ÖËùʾ£¬Ó¦¸ÃÏÈÓöþ½øÖÆ·½Ê½¶Á½øÀ´£¬È»ºóÔÙת»¯Îªutf-8·½Ê½£¬ºÍÊý¾Ý¿âÖеıàÂëÒ»Ö¡£
ÏÂÃæÊÇ֮ǰÅöµ½¹ýµÄÒ»¸öÀý×Ó£¬´Óweb·þÎñÆ÷¶ÁÈ¡Êý¾Ý£¬²¢×ª»¯Îªutf-8¡£web·þÎñÆ÷ʹÓõÄÊÇiso-8859-1±àÂë¡£
ͬÑùÒ²ÊÇÏÈÓÃgetbytes·½Ê½ÏÈ»ñÈ¡¶þ½øÖÆÁ÷£¬È»ºóת³Éutf-8¡£
-------------------------------------------------------------------------------------------
3¸öµØ·½ÉèÖñàÂ룬½â¾öÂÒÂëÎÊÌâ
public static String GetResponse(HttpMethodBase Method) throws IOException {
String charset= Method.getResponseCharSet();
System.out.println("·µ»ØµÄ×Ö·û±àÂëΪ£º"+charset);
InputStream responseBody = Method.getResponseBodyAsStream();
// BufferedReader br = new BufferedReader(new InputStreamReader(responseBody));
BufferedReader br = new BufferedReader(new InputStreamReader(Method.getResponseBodyAsStream(), "ISO-8859-1"));//1
String tempbf;
StringBuffer htmlbf = new StringBuffer(100);
while ((tempbf = br.readLine()) != null) {
// htmlbf.append(tempbf);
htmlbf.append(new String(tempbf.getBytes("iso-8859-1"),"utf-8"));//2
htmlbf.append("\n");
Ïà¹ØÎĵµ£º
<>ÕûÀíÁËÒÔÏÂËÄÖÖÔÚMySQLÖÐÐÞ¸ÄrootÃÜÂëµÄ·½·¨,¿ÉÄܶԴó¼ÒÓÐËù°ïÖú!
·½·¨1£º ÓÃSET PASSWORDÃüÁî
¡¡¡¡mysql -u root
¡¡¡¡mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
·½·¨2£ºÓÃmysqladmin
¡¡¡¡mysqladmin -u root password "newpass"
¡¡¡¡Èç¹ûrootÒѾÉèÖà ......
my.iniÀïµÄÄǸötmp_table_sizeµÄÖµ.ÔÀ´tmp_table_size=16M.ÎÒ¸ÄΪ32M
È»ºóÖØÆôMYSQL»¹ÊÇû½â¾öÎÊÌâ.
Ö»ºÃÖØÆô·þÎñÆ÷ÊÔÊÔÁË,½á¹ûÖØÆôºóCPUÕý³£ÁË.²»¹ý»¹ÊÇûÕÒ³öÊÇʲôÔÒòµ¼ÖÂMYSQLÕ¼ÓÃÄÇô¶àCPU×ÊÔ´.
=====================================
ÐÞ¸ÄhostsÎļþ£¬¼ÓÈëÒ»ÐÐ
172.16.59.12 & ......
Ê×ÏÈÍ£Ö¹MySQL·þÎñ£ºsudo /etc/init.d/mysql stop
È»ºó±à¼MySQLÅäÖÃÎļþ£ºsudo gedit /etc/mysql/my.cnf
ÔÚmy.cnfÎļþÖеÄ[client]¶ÎÏÂÃæ¼ÓÈë
default-character-set=utf8
[mysqld_safe]
default-character-set=utf8
[mysqld]
default-character-set=utf8
[mysql]
default-character-set=utf8
ÖØÐÂÆô¶¯MySQL·þÎñ ......
Ò»¡¢»ù´¡
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
Create DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
--- ¿ªÊ¼ ±¸·Ý
BACKUP DATABASE pubs TO testBack
4 ......
ÎÒ¸Õ´ÓÔÚAntwerpÕÙ¿ªµÄDevoxx
´ó»áÉÏ»ØÀ´£¬»áÉϽéÉÜÁËJava7µÄÐÂÌØÐÔ£¬¶ÔÓ¦µÄJDK½«ÓÚ2010Äê9Ô·¢²¼¡£
ÏÂÃæÊÇ7¸öÒѾÍê³ÉµÄÐÂÌØÐÔ£º
¶ÔcollectionsµÄÓïÑÔ¼¶Ö§³Ö
×Ô¶¯×ÊÔ´¹ÜÀí
¸Ä½ø·ºÐÍÔÚ´´½¨ÊµÀýʱµÄÀàÐÍÒýÓÃ
´øÏ»®ÏßµÄÊý×Ö
ÔÚswitchÖÐʹÓÃString
¶þ½øÖÆÎÄ×Ö
¼ò»¯µÄ¿É±ä²ÎÊý·½·¨µ÷ÓÃ
Java7»¹ÓкܶàÆäËûµÄÐÂÌØÐÔ£¬Î ......