javaÓëmysqlÂÒÂëµÄÎÊÌâ
javaÓëmysqlÂÒÂëµÄÎÊÌâ
javaÓëmysqlÂÒÂëµÄÎÊÌâ
¹Ø¼ü×Ö: javaÓëmysqlÂÒÂëµÄÎÊÌâ
½â¾ö·½·¨Ò»:(×îÖØÒªµÄÒ»ÖÖ·½·¨)
Äã¿´ÏÂmy.ini£¬ÓÐÎÞ
[mysql]
default-character-set=utf8
[client]
default-character-set=utf8
[mysqld]
default-character-set=utf8
È»ºó½¨Á¢±íʱ£¬Ò²ÒªÓ㨱ÈÈ磩
DROP TABLE IF EXISTS `Company`;
CREATE TABLE IF NOT EXISTS `Company`
(
`Cname` VARCHAR(10) NOT NULL,
`Caddr` VARCHAR(100),
`Ctel` VARCHAR(16)
)ENGINE=InnoDB DEFAULT CHARSET=UTF8;
ÕâÑù¾ÍûÎÊÌâ¡£
Èç¹ûÊÇjspÒªÉùÃ÷£º
contentType="text/html;charset=gb2312"
½â¾ö·½·¨¶þ£º
Á¬½Ómysqlʱ(ÎÞÂÛÔÚ´Ómysql¶Á»¹ÊÇÈ¡Êý¾ÝµÄÇé¿ö)£¬Ö¸¶¨Ê¹ÓõıàÂ뷽ʽΪutf-8£¬¾ßÌå´úÂëÈçÏÂ
//×°ÔØmysql-jdbcÇý¶¯
Class.forName("com.mysql.jdbc.Driver").newInstance();
//Á¬½ÓÊý¾Ý¿â
Connection sqlCon = DriverManager.getConnection( "jdbc:mysql://localhost:3306/test? user=root&password=1&useUnicode=true&characterEncoding=utf-8" );
½â¾ö·½·¨Èý£º
Èç¹û·½·¨Ò»²»ÐÐÄÇôÔÚ·½·¨Ò»µÄ»ù´¡É϶ԶÁÈëµÄ×Ö·û´®½øÐÐÇ¿ÖÆ±àÂ뷽ʽת»»¡£
´úÂëʾÀýÈçÏ£º
String name = rst.getString("name");
name= new String(name.getBytes("ISO-8859-1"),"utf-8");
×¢£º´úÂëÒ²¿ÉÒÔΪ£ºString name =new String( rst.getString("name").getBytes("ISO-8859-1"),"utf-8"));ÆäÖÐrstΪ·µ»ØµÄresultset,ISO-8859-1ΪmysqlĬÈϵıàÂ뷽ʽ£¬´úÂëµÄÄ¿µÄÊǰÑÒÔISO-8859-1µÄ±àÂëת»»Îªgb2312±àÂ뷽ʽ£¬ÕâÑùÇ¿ÖÆ×ª»»£¬¿ÉÒÔ½â¾öÒ»²¿·ÖÎÊÌ⣬Èç¹û½áºÏ·½·¨Ò»£¬Ó¦¸Ã¿ÉÒÔ½â¾öÖÐÎÄÂÒÂëÎÊÌâ¡£
½â¾ö·½·¨ËÄ£º
Õâ¸ö·½·¨ÔÚÓÐЩÎÄÕÂÀïÊÇÊ×ÍÆµÄ£¬ÎÒÊ×ÏÈÒ²ÊÇÊÔÁËÕâ¸ö·½·¨£¬µ«ÊǺÃÏñ²»ÐС£ÕâÀﻹÊÇ˵һÏ£¬²»ÖªÊDz»ÊÇÎÒ²Ù×÷´íÎó¡£»¹ÊÇÏÈÌùÔÎİɣº
"Èç¹ûÊý¾Ý¿âÖÐÓÐÖÐÎĵϰ¶ømysqlĬÈϵÄÓïÑÔ²»ÊÇÖÐÎÄʱҪÔÚÅäÖÃÎļþC:winntmy.ini ÖÐµÄ [mysqld] ÀïÌí¼ÓÒ»ÐУº
default-character-set=utf-8
È»ºóÖØÆðmysql
·½·¨Î壺ÔÚtomcat conf ÀïÃæµÄweb.xmlÀïÃæ¸ü¸Ä£º
<filter>
<filter-name>UTFEncoding</filter-name>
<filter-class>com.founder.chenph.Util.EncodingFilter_UTF8
</filter-class>
<
Ïà¹ØÎĵµ£º
Ôڳɹ¦ÊµÏÖJavaµ÷ÓÃC++Ö®ºó£¬½ÓÏÂÀ´Ïëµ½ÄÜ·ñͨ¹ýJNAʵÏÖJavaµ÷ÓÃFortran£¬½ñÌìÊÔÑéÁËһϣ¬»¹ÊDZȽÏÈÝÒ׵ġ£
ÍøÉÏÓÐÒ»¸öJavaµ÷ÓÃF95µÄÀý×Ó£¬µ«ÊÇÎÒ¿¼ÂDz»½öҪʵÏÖF95µÄµ÷Ó㬻¹ÒªÊµÏÖF77µÄµ÷Óã¬ËùÒÔ·ÑÁËһЩÖÜÕÛ¡£
ÎÊÌâµÄ¹Ø¼üÔÚÓÚF77Ϊ¹ý³ÌÃû×Ô¶¯Ìí¼ÓÁËÒ»¸öβ²¿µÄÏ»®Ïߣ¬ËùÒÔsub1Õâ¸ö¹ý³Ì£¬µ½JavaÒ»¶Ë£¬¾Í±ä³ÉÁËsub1_£¬ ......
תÌù£º
ÏÖÔÚÓÃlinuxµÄÅóÓÑÔ½À´Ô½¶àÁË£¬Ç°¼¸Ìì¾ÍÓÐÁ½¸öÅóÓÑÎÊÎÒlinuxÏÂÔõôÅäÖÃjava»·¾³£¬ÎÒÏ뻹ÓкܶàÅóÓÑÏëÁ˽âѧϰÕâ·½ÃæµÄ¶«Î÷£¬¾Íдһ¸öÍêȫһµãµÄlinux java»·¾³ÅäÖðɣ¬Ï£Íû¶Ô´ó¼ÒÓаïÖú¡£
Ò». ÏÂÔØjdk5.0 for linux
¡¡¡¡µ½sunµÄÖ÷Ò³ http://java.sun.com/j2se/1.5.0/download.jsp ÏÂÔØjdk°²×°Îļþjdk-1_5_0_05-li ......
ÏÂÃæµÄ³ÌÐò±»Éè¼ÆÓÃÀ´´òÓ¡ËüµÄÀàÎļþµÄÃû³Æ¡£Èç¹ûÄã²»ÊìϤÀà×ÖÃæ³£Á¿£¬ÄÇôÎÒ¸æËßÄãMe.class.getName()½«·µ»ØMeÀàÍêÕûµÄÃû³Æ£¬¼´“com.javapuzzlers.Me”¡£ÄÇô£¬Õâ¸ö³ÌÐò»á´òÓ¡³öÊ²Ã´ÄØ£¿
package com.javapuzzlers;
public class Me {
public static void main(String[] args){
System.out.pr ......
ÏÂÃæµÄ³ÌÐòÑ»·±éÀúbyteÊýÖµ£¬ÒÔ²éÕÒij¸öÌØ¶¨Öµ¡£Õâ¸ö³ÌÐò»á´òÓ¡³öÊ²Ã´ÄØ£¿
public class BigDelight {
public static void main(String[] args) {
for (byte b = Byte.MIN_VALUE; b < Byte.MAX_VALUE; b++) {
if (b == 0x90)
System.out.print("Joy!");
}
......
ÓëÃÕÌâ26ÖеijÌÐòÒ»Ñù£¬ÏÂÃæµÄ³ÌÐòÒ²°üº¬ÁËÒ»¸ö¼Ç¼ÔÚÖÕֹǰÓжàÉٴεü´úµÄÑ»·¡£ÓëÄǸö³ÌÐò²»Í¬µÄÊÇ£¬Õâ¸ö³ÌÐòʹÓõÄÊÇ×óÒÆ²Ù×÷·û£¨<<£©¡£ÄãµÄÈÎÎñÕÕ¾ÉÊÇÒªÖ¸³öÕâ¸ö³ÌÐò½«´òӡʲô¡£µ±ÄãÔĶÁÕâ¸ö³ÌÐòʱ£¬Çë¼Çס Java ʹÓõÄÊÇ»ùÓÚ2µÄ²¹ÂëµÄ¶þ½øÖÆËãÊõÔËË㣬Òò´Ë-1ÔÚÈκÎÓзûºÅµÄÕûÊýÀàÐÍÖУ¨byte¡¢short¡¢int»òlong£ ......