JAVA JDBC(MySQL)Çý¶¯Ô´Âë·ÖÎö(ËÄ)
connect·½·¨ÊÇjava.sql.Driver½Ó¿ÚÖж¨ÒåµÄ·½·¨£¬Èç¹ûÁ¬½ÓµÄÊý¾Ý¿â²»Í¬£¬ÄÇôΪ²»Í¬µÄÊý¾Ý¿â±àдJDBCÇý¶¯½«±äµÃºÜÁé»î£¬ÊµÏÖDriver½Ó¿Ú¼´¿É¡£Á¬½ÓÊý¾Ý¿âʱÊ×ÏȵÃ×°ÔØJDBCÇý¶¯£¬Ò²¾ÍÊǵ÷Óà Class.forName(“com.mysql.jdbc.Driver”)·½·¨£¬ÔÚµÚһƪÖÐÒѾÁгömysql jdbc DriverÀàµÄÔ´Â룬´ËÀà¼Ì³ÐNonRegisteringDriverͬʱʵÏÖÁËjava.sql.Driver½Ó¿Ú¡£ÕÒµ½NonRegisteringDriverÀà»á·¢ÏÖËüҲʵÏÖÁËjava.sql.Driver½Ó¿Ú£º
public class NonRegisteringDriver implements java.sql.Driver {
……
}
ÔÚgetConnection·½·¨ÖÐÓÐÈçÏÂÒ»¾ä´úÂ룬
Connection result = di.driver.connect(url, info);
diÊÇDriverInfoÀàÐ͵ĶÔÏ󣬴˶ÔÏóÖаüº¬ÁËDriverµÄÒýÓ㬵«ÊÇÔÚcom.mysql.jdbc.DriverÀàÖÐÖ»ÓÐÒ»¸ö¾²Ì¬¿éºÍÒ»¸ö¹¹Ôì·½·¨£¬ÄÇôconnect·½·¨ÓпÉÄÜÊÇÔÚÆä¸¸ÀàÖÐʵÏÖ¡£ÈçǰËùÊö£¬¸¸ÀàΪNonRegisteringDriver£¬ÔÚmysqlÇý¶¯°üµÄÔ´ÂëÖпÉÒÔÕÒµ½´ËÀà,£º
com.mysql.jdbc.NonRegisteringDriver
ÄÇôdi.driver.connect(url, info) µ÷ÓõÄconnect·½·¨¾ÍÊÇNonRegisteringDriverÀàÖеÄconnect·½·¨£¬Ô´ÂëÈçÏÂ:
public java.sql.Connection connect(String url, Properties info)
throws SQLException {
if (url != null) {
if (StringUtils.startsWithIgnoreCase(url, LOADBALANCE_URL_PREFIX)) {
return connectLoadBalanced(url, info);
} else if (StringUtils.startsWithIgnoreCase(url,
REPLICATION_URL_PREFIX)) {
return connectReplicationConnection(url, info);
}
}
Properties props = null;
if ((props = parseURL(url, info)) == null) {
return null;
}
try {
Connection newConn = com.mysql.jdbc.ConnectionImpl.getInstance(
host(props), port(props), props, database(props), url);
return newConn;
} catch (SQLException sqlEx) {
// Don't wrap SQLExceptions, throw
// them un-changed.
throw sqlEx;
} catch (Exception ex) {
SQLException sqlEx = SQLError.createSQLException(Messages
.getString("NonRegisteringDriver.17") //$NON-NLS-1$
+ ex.toString()
+ Messages.getString("NonRegisteringDriver.18"), //$NON-NLS-1$
SQLError.SQL_STATE_UNABLE_TO_CONN
Ïà¹ØÎĵµ£º
MySQLÐÔÄÜÓÅ»¯µÄ×î¼Ñ20+Ìõ¾Ñé
½ñÌ죬Êý¾Ý¿âµÄ²Ù×÷Ô½À´Ô½³ÉΪÕû¸öÓ¦ÓõÄÐÔÄÜÆ¿¾±ÁË£¬Õâµã¶ÔÓÚWebÓ¦ÓÃÓÈÆäÃ÷ÏÔ¡£¹ØÓÚÊý¾Ý¿âµÄÐÔÄÜ£¬Õâ²¢²»Ö»ÊÇDBA²ÅÐèÒªµ£ÐĵÄÊ£¬¶øÕâ¸üÊÇÎÒÃdzÌÐòÔ±ÐèҪȥ¹Ø×¢µÄÊÂÇé¡£µ±ÎÒÃÇÈ¥Éè¼ÆÊý¾Ý¿â±í½á¹¹£¬¶Ô²Ù×÷Êý¾Ý¿âʱ£¨ÓÈÆäÊDzé±íʱµÄSQLÓï¾ä£©£¬ÎÒÃǶ¼ÐèҪעÒâÊý¾Ý²Ù×÷µÄÐÔÄÜ¡£ÕâÀÎÒÃDz»» ......
ÔÚа²×°ºÃµÄmysql £¬apahce£¬php µÄʱºò£¬Èç¹ûÔÚ´úÂëÖÐʹÓÃÁËsessions_start() µÄʱºò»á³öÏÖÀàËÆÒÔϵĴíÎó£º
Warning: session_start() [function.session-start]: Cannot send session cooki µÈµÄ´íÎó¡£
Çë°²×°ÈçϵÄ˼·ȥÐÞÕý£º
1.ÔÚphp.ini ÖÐÅäÖÃ session.savepath='/tmp'
2.¿ªÆôsession.auto_start=1
3.°Ñ¸ü¸Ä ......
×î½üÓöµ½ÁËÒ»¸öÎÊÌ⣬¾ÍÊÇÔÚÓõ½List.toArray ·½·¨Ê±£¬·µ»ØObject[]Êý×飬ֱ½Ó°ÑËüǿת³ÉÆäËûÀàÐ͵Ļᱨ´í£º
code: ArrayList list=getList();
String[] s=(String[])list.toArray();
except ......
²ÉÓÃÓûÑïÏÈÒÖµÄÊÖ·¨Ì¸Ì¸java:
javaûÓÐÖ¸ÕëÖ»ÓÐÒýÓÃÊÇ×î´óµÄ°Ü±Ê.ÕýÒòΪûÓÐÖ¸Õë,ºÜ¶à²Ù×÷ÒªÓØ»ØÍñת;À¬»øÊÕ¼¯»úÖÆÒ²¾õµÃÊǼ¦Àß,д¸öÎö¹¹º¯ÊýÕæµÄÄÇô¸´ÔÓÂð, ÓбØÒªÎþÉüÁé»îÐÔÂð;º¯Êýµ÷ÓõĴú¼ÛÖ®¸ßÈÃÈË×¥¿ñ
µ«ÎÒ»¹ÊÇÑ¡ÔñÁËËý:
javaµÄ´¿ÃæÏò¶ÔÏóÌØ ......
ÐòÁл¯µÄ¹ý³Ì¾ÍÊǶÔÏóдÈë×Ö½ÚÁ÷ºÍ´Ó×Ö½ÚÁ÷ÖжÁÈ¡¶ÔÏó¡£½«¶ÔÏó״̬ת»»³É×Ö½ÚÁ÷Ö®ºó£¬¿ÉÒÔÓÃjava.io°üÖеĸ÷ÖÖ×Ö½ÚÁ÷ÀཫÆä±£´æµ½ÎļþÖУ¬¹ÜµÀµ½ÁíÒ»Ïß³ÌÖлòͨ¹ýÍøÂçÁ¬½Ó½«¶ÔÏóÊý¾Ý·¢Ë͵½ÁíÒ»Ö÷»ú¡£¶ÔÏóÐòÁл¯¹¦Äܷdz£¼òµ¥¡¢Ç¿´ó£¬ÔÚRMI¡¢Socket¡¢JMS¡¢EJB¶¼ÓÐÓ¦Ó᣶ÔÏóÐòÁл¯ÎÊÌâÔÚÍøÂç±à³ÌÖв¢²»ÊÇ× ......