java Á¬½Ó mysql
µ±È»£¬Ê×ÏÈÒª°²×°ÓÐJDK(Ò»°ãÊÇJDK1.5.X)¡£È»ºó°²×°MySQL£¬ÕâЩ¶¼±È½Ï¼òµ¥£¬¾ßÌå¹ý³Ì¾Í²»ËµÁË¡£ÅäÖúÃÕâÁ½¸ö
»·¾³ºó£¬ÏÂÔØJDBCÇý¶¯mysql-connector-java-5.1.5.zip£¨http://www.ntu-w.lkams.kernel.org/pub/MySQL/Downloads/Connector-J/mysql-connector-java-5.1.5.zip£©¡£È»ºó½«Æä½âѹËõµ½ÈÎһĿ¼¡£ÎÒÊǽâѹµ½DÅÌ£¬È»ºó½«ÆäĿ¼ÏµÄmysql-connector-java-5.0.5-bin.jar¼Óµ½classpathÀ¾ßÌåÈçÏ£º“ÎҵĵçÄÔ”-> “ÊôÐÔ” -> “¸ß¼¶” -> “»·¾³±äÁ¿”£¬ÔÚϵͳ±äÁ¿ÄÇÀï±à¼classpath£¬½«D:\mysql-connector-java-5.0.5\mysql-connector-java-5.0.5-bin.jar¼Óµ½×îºó£¬ÔÚ¼ÓÕâ¸ö×Ö·û´®Ç°Òª¼Ó“;”£¬ÒÔÓëǰһ¸öclasspathÇø·Ö¿ª¡£È»ºóÈ·¶¨¡£»·¾³ÅäÖúÃÁË£¬ºÜ¼òµ¥¡£ÏÖÔÚ£¬ÏÈÅäÖÃMySQL£¬ÉèÆäÓû§ÃûΪ“root”£¬ÃÜÂëΪ“root”¡£ÔÚÃüÁîÐлòÓÃÒ»¸öSQLµÄǰ¶ËÈí¼þ´´½¨Database¡£
ÔÚeclipseÖе¼Èëjdbc¾Í¿ÉÒÔÁË.·½·¨ÈçÏÂ:ÔËÐÐeclipse,´°¿Ú->Ê×Ñ¡Ïî->java->ÒѰ²×°µÄjre->(Ñ¡ÖÐÆäÖÐÒ»¸ö)->±à¼->È¡ÏûϵͳĬÈÏjre->Ìí¼ÓÍⲿjre->ÕÒµ½jdbcÎļþ¼ÐÖеÄmysql-connector-java-5.0.0-beta-bin.jar(¸ÃÏî¿ÉÄܲ»Ëù²»Í¬,²»¹ýûÓйØÏµ)->È·¶¨.ÄÇô¾Í¿ÉÒÔÔÚeclipseÖÐʹjavaÓëmysqlÁ¬½ÓÁË.
ÏÈ´´½¨Êý¾Ý¿â£º
CREATE DATABASE SCUTCS;
½Ó×Å£¬´´½¨±í£º
CREATE TABLE STUDENT
(
SNO CHAR(7) NOT NULL,
SNAME VARCHAR(8) NOT NULL,
SEX CHAR(2) NOT NULL,
BDATE DATE NOT NULL,
HEIGHT DEC(5,2) DEFAULT 000.00,
PRIMARY KEY(SNO)
);
È»ºó²åÈëÊý¾Ý£¬¿ÉÒÔÓÃSQLÓï¾äinsert into <±íÃû> values (value1, value2, ...);
Ò²¿ÉÒÔÓÃSQLyogÀ´²Ù×÷
ºÃÁË£¬´´½¨ºÃÁË¡£
ÏÂÃæ£¬ÎÒÃÇÀ´±àд.javaÎļþÀ´ÑÝʾһÏÂÈçºÎ·ÃÎÊMySQLÊý¾Ý¿â¡£
import java.sql.*;
public class JDBCTest {
public static void main(String[] args){
// Çý¶¯³ÌÐòÃû
String driver = "com.mysql.jdbc.Driver";
&nbs
Ïà¹ØÎĵµ£º
Java Learning Path £¨Ò»£©¡¢¹¤¾ßƪ
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJDKÊÇSun¹«Ë¾·¢²¼µÄJDK£¬³ýÁËSunÖ®Íâ ......
Õâ¸öÔÔòºÜ¼òµ¥£¬¾ÍÊÇʹÓÃ˽Óй¹Ô캯Êý·ÀÖ¹À౻ʵÀý»¯¡£ ÓÐʱ£¬ÎÒÃÇ»áдһЩ¹¤¾ßÀ࣬Èçjava.lang.Math »òÊÇ java.util.Arrays, ÕâЩÀàÖж¼ÊǾ²Ì¬º¯Êý£¬ÔÚÉè¼ÆµÄʱºò£¬ÕâЩÀಢ²»ÊÇÓÃÀ´±»ÊµÀý»¯µÄ¡£Õâ¸öʱºò£¬¾ÍºÜÓбØÒª°Ñ¹¹Ô캯Êý˽Óл¯¡£ public class UtilityClass {
private UtilityClass() {
throw ne ......
¶ÔÓÚÕâ¸öϵÁÐÀïµÄÎÊÌ⣬ÿ¸öѧJavaµÄÈ˶¼Ó¦¸Ã¸ã¶®¡£µ±È»£¬Èç¹ûÖ»ÊÇѧJavaÍæÍæ¾ÍÎÞËùνÁË¡£Èç¹ûÄãÈÏΪ×Ô¼ºÒѾ³¬Ô½³õѧÕßÁË£¬È´²»ºÜ¶®ÕâЩÎÊÌ⣬Ç뽫Äã×Ô¼ºÖعé³õѧÕßÐÐÁС£ÄÚÈݾùÀ´×ÔÓÚCSDNµÄ¾µäÀÏÌù¡£
ÎÊÌâÒ»£ºÎÒÉùÃ÷ÁËʲô£¡
String s = "Hello world!";
¡¡Ðí¶àÈ˶¼×ö¹ýÕâÑùµÄÊÂÇ飬µ«ÊÇ£¬ÎÒÃǵ½µ×ÉùÃ÷ÁËʲô£¿»Ø´ðͨ ......
ÉùÃ÷£ºJavaEyeÐÂÎÅÎÄÕµİæÈ¨ÊôÓÚJavaEyeÍøÕ¾ËùÓУ¬ÑϽûÈκÎÍøÕ¾×ªÔØ±¾ÎÄ£¬·ñÔò±Ø½«×·¾¿·¨ÂÉÔðÈΣ¡
ÍÆ¼öÊ®¸ö×îºÃµÄJavaÐÔÄܹÊÕÏÅųý¹¤¾ß£º
1.jconsoleÊÇËæ×ÅJDK 1.5¶øÍƳöµÄ¡£ÕâÊÇÒ»¸öJava¼à²âºÍ¹ÜÀí¿ØÖÆÌ¨-JMX¼æÈݵÄͼÐι¤¾ßÀ´¼à²âJavaÐéÄâ»ú¡£ËüÄܹ»Í¬Ê±¼à²â±¾µØºÍÔ¶³ÌµÄJVMs¡£ÏêÇé¿É²é¿´£ºjconsole¹¤¾ß½ ......