MySQL Connector/JÊÇMySQL¹Ù·½JDBCÇý¶¯³ÌÐò¡£½«ÏÂÔصÄÇý¶¯°ü½âѹËõºó£¬½«MySQL-connector-Java-5.1.41-bin.jar¿½±´µ½ÏîÄ¿ÖÐ
Connector/J 5.41°üÀ¨JDBC-4.0¹¦ÄܵÄÖ§³Ö
°üÀ¨£º
Ò×ÓÚ¿ª·¢µÄÌص㣬°üÀ¨Í¨¹ý×Ô¶¯×¢²á·þÎñÌṩÉÌ»úÖÆ£¬±ê×¼»¯µÄÁ¬½ÓÓÐЧÐÔ¼ì²éºÍ·ÖÀàµÄSQLExceptionsµÄ»ù´¡ÉϿɻָ´/ÖØÊÔÄÜÁ¦ºÍÒ»Á÷µÄµ×²ã´íÎó¡£
DriverManager¸ôÀë
½â¿ª°üÀ¨¹©Ó¦ÉÌÀ©Õ¹µ½½Ó¿Ú
ͨ¹ýJAXP½Ó¿ÚÖ§³ÖÓÃÓÚXML´¦ÀíDOM£¬SAXºÍStAX
Ö§³ÖÉèÖÃÿ¸öÁ¬½ÓµÄ¿Í»§¶ËÐÅÏ¢£¨¿ÉÒԲ鿴²éѯµÄÒâ¼ûͨ¹ý¡°SHOW PROCESSLISTµÄ¡±Ò»¸öMySQL·þÎñÆ÷ÉÏ£¬»òͨ¹ýÒ»¸ö¹«¹²½Ó¿Ú£¬¿ÉÀ©Õ¹£¬ÒÔÖ§³Ö×Ô¶¨Òå³Ö¾ÃÐÔµÄÐÅÏ¢£©
JDBC-4.0 NCHAR£¬NVARCHARºÍNCLOBÀàÐ͵ÄÖ§³Ö
ʹÓÃʾÀý£º
1¡¢½«ÆäÖеÄJava°ü£¨mysql-connector-java-5.1.26-bin.jar£©£¬¸´ÖƵ½MySQLĿ¼ÏÂ(½öÊÇΪÁË·½±ã²Å·Åµ½ÕâÀï)£¬ÒÔ±¸¼ÓÔØÇý¶¯³ÌÐòʱʹÓá£
2¡¢´´½¨Êý¾Ý¿â£ºÊ¹ÓÃphpMyAdmin£¬µÇ¼MySQL£¬´´½¨Êý¾Ý¿âmyuser£¬²¢ÔÚÆäÖвåÈëÒ»¸öÃûΪstaffµÄ±í¸ñ¡£²¢Ìí¼ÓһЩÊý¾Ý£¬²Ù×÷²½ÖèÈçͼ£¬µÇ¼½øÈ¥MySQLÊý¾Ý¿âºó£º
1£©´´½¨Êý¾Ý¿â£¬Ãû³ÆΪmyuser£¬±àÂëΪutf8_general_ci£¨Ö§³ÖÖÐÎÄ£©£»
2£©Ð½¨±í¸ñ£¬Ãû³ÆΪstaff£¬±í¸ñÓÐ8¸ö×ֶΣ»
3£©8¸ö×ֶεÄÉèÖ㬰üÀ¨Ãû³Æ¡¢ÀàÐÍ¡¢ÖµµÄ³¤¶È¡¢³õʼֵ¡¢±àÂëµÈµÈ(µã»÷²é¿´´óͼ)£»
4£©Ìí¼Ó³É¹¦ºó£¬²é¿´µÄstaff±í¸ñÇé¿ö£º
5£©Íù±í¸ñÖвåÈëһЩʵÑéËùÐèÊý¾Ý£¬ÐèÒª²åÈëÁ½Ìõ£¬Ò»¸öÊÇÔ±¹¤lucyµÄ£¬»¹ÓÐliliµÄ£º
3¡¢ÔÚMyEclipsÖд´½¨ÏîÄ¿²¢ÔÚÏîÄ¿ÖÐÌí¼ÓMySQLÇý¶¯³ÌÐò£º´´½¨µÄÏîÄ¿ÀàÐÍ¿ÉÒÔÊÇJavaÏîÄ¿»òÕßÊÇJava WebÏîÄ¿¶¼¿ÉÒÔ¡£ÕâÀï´´½¨µÄÊÇWebÏîÄ¿£¬ÏîÄ¿Ãû³Æ¿ÉÒÔËæ±ãÈ¡£¬ÎÒÃüÃûΪ¡°JavaWebChp07¡±¡£´´½¨³É¹¦ºó½«²½Öè1ÀïÏÂÔصõ½µÄMySQLÇý¶¯³ÌÐò°ü£¨mysql-connector-java-5.1.18-bin.jar£©Ìí¼Óµ½¹¤³ÌµÄBuild pathÖУ¬Ìí¼Ó¹ý³ÌÈçͼËùʾ£º
4¡¢±àдJDBCÁ¬½ÓMySQLÊý¾Ý¿âµÄʵÀý¾ßÌå´úÂ룬JDBC_Test.java£º
mysql×¢²áÇý¶¯·½·¨£º
1:Class.forName("com.mysql.jdbc.Driver");
2:DriverManager.registerDriver(new Driver());
3:System.setProperty("jdbc:drivers", "com.mysql.jdbc.Driver");
jdbcÁ¬½Óoracle¡¢mysqlµÈÖ÷Á÷Êý¾Ý¿âµÄÇý¶¯ÀàºÍurl£º
oracle
driverClass£ºoracle.jdbc.driver.OracleDriver
url£ºjdbc:oracle:thin:@127.0.0.1:1521:dbname
-----------------------------------------------------------
mysql
driverClass£ºcom.mysql.jdbc.Driver
url£ºjdbc:mysql://localhost:3306/mydb
PS£ºÓеÄʱºò£¬mysqlµÄÇý¶¯ÀàÒ²Ò²»á¿´µ½Ê¹ÓÃorg.gjt.mm.mysql.DriverµÄÇé¿ö£¬
org.gjt.mm.mysql.DriverÊÇÔçÆÚµÄÇý¶¯Ãû³Æ£¬ºóÀ´¾Í¸ÄÃûΪcom.mysql.jdbc.Driver£¬
ÏÖÔÚÒ»°ã¶¼ÍƼöʹÓà com.mysql.jdbc.Driver¡£ÔÚ×îа汾µÄmysql jdbcÇý¶¯ÖУ¬ÎªÁ˱£³Ö¶ÔÀÏ°æ±¾µÄ¼æÈÝ£¬ÈÔÈ»±£ÁôÁËorg.gjt.mm.mysql.Driver£¬µ«ÊÇʵ¼ÊÉÏ org.gjt.mm.mysql.DriverÖе÷ÓÃÁËcom.mysql.jdbc.Driver£¬Òò´ËÏÖÔÚÕâÁ½¸öÇý¶¯Ã»ÓÐʲôÇø±ð¡£
-----------------------------------------------------------
DB2
driverClass£ºcom.ibm.db2.jcc.DB2Driver
url£ºjdbc:db2://127.0.0.1:50000/dbname
-----------------------------------------------------------
syBase
driverClass£ºcom.sybase.jdbc.SybDriver
url£ºjdbc:sybase:Tds:localhost:5007/dbname
-----------------------------------------------------------
PostgreSQL
driverClass£ºorg.postgresql.Driver
url£ºjdbc:postgresql://localhost/dbname
-----------------------------------------------------------
Sql Server2000
driverClass£ºcom.microsoft.jdbc.sqlserver.SQLServerDriver
url£ºjdbc:microsoft:sqlserver://localhost:1433;DatabaseName=dbname
-----------------------------------------------------------
Sql Server2005
driverClass£ºcom.microsoft.sqlserver.jdbc.SQLServerDriver
url£ºjdbc:sqlserver://localhost:1433; DatabaseName=dbname