谁可相欹 发表于 2015-1-18 11:51:44

JAVA网页编程之Driver Class Name and JDBC URL Forma...

对于一个大型项目,如果用java来作,可能需要9个月,并且可能需要翻阅10本以上的书,但如果用ruby来作,3个月,3本书就足够了,而.net也不过3,4本书足以,这就是区别。
Thenameoftheclassthatimplementsjava.sql.DriverinMySQLConnector/Jiscom.mysql.jdbc.Driver.Theorg.gjt.mm.mysql.Driverclassnameisalsousabletoremainbackwards-compatiblewithMM.MySQL.Youshouldusethisclassnamewhenregisteringthedriver,orwhenotherwiseconfiguringsoftwaretouseMySQLConnector/J.

TheJDBCURLformatforMySQLConnector/Jisasfollows,withitemsinsquarebrackets([,])beingoptional:
jdbc:mysql://[,failoverhost...][:port]/[?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]...
Ifthehostnameisnotspecified,itdefaultsto127.0.0.1.Iftheportisnotspecified,itdefaultsto3306,thedefaultportnumberforMySQLservers.

Startingwithversion3.0.12and3.1.2,Connector/Jsupportsmultiplehostswithports,separatedbycommas:
jdbc:mysql://,.../[?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]...
Ifthedatabaseisnotspecified,theconnectionwillbemadewithnocurrentdatabase.Inthiscase,youwillneedtoeithercallthesetCatalog()methodontheConnectioninstance,issueaUSEdbnamequeryorfully-specifytablenamesusingthedatabasename(i.e.SELECTdbname.tablename.colnameFROMdbname.tablename...)inyourSQL.Notspecifyingthedatabasetouseuponconnectionisgenerallyonlyusefulwhenbuildingtoolsthatworkwithmultipledatabases,suchasGUIdatabasemanagers.

MySQLConnector/Jhasfail-oversupport.Thisallowsthedrivertofail-overtoanynumberof"slave"hostsandstillperformread-onlyqueries.Fail-overonlyhappenswhentheconnectionisinanautoCommit(true)state,becausefail-overcannothappenreliablywhenatransactionisinprogress.MostgoodapplicationserversandconnectionpoolssetautoCommittotrueattheendofeverytransaction/connectionuse.Thefail-overfunctionalityhasthefollowingbehavior:IftheURLproperty"autoReconnect"isfalse:Failoveronlyhappensatconnectioninitialization,andfailbackoccurswhenthedriverdeterminesthatthefirsthosthasbecomeavailableagainIftheURLproperty"autoReconnect"istrue:Failoverhappenswhenthedriverdeterminesthattheconnectionhasfailed(beforeeveryquery),andfallsbacktothefirsthostwhenitdeterminesthatthehosthasbecomeavailableagain(afterqueriesBeforeRetryMasterquerieshavebeenissued).Ineithercase,wheneveryouareconnectedtoa"failed-over"server,theconnectionwillbesettoread-onlystate,soqueriesthatwouldmodifydatawillhaveexceptionsthrown(thequerywillneverbeprocessedbytheMySQLserver).

YoumayspecifyadditionalpropertiestotheJDBCdriver,eitherbyplacingtheminajava.util.PropertiesinstanceandpassingthatinstancetotheDriverManagerwhenyouconnect,orbyaddingthemtotheendofyourJDBCURLasname-valuepairs.Thefirstpropertyneedstobepreceededwitha?character,andadditionalname-valuepairpropertiesareseparatedbyan&character.Theproperties,theirdefinitionsandtheirdefaultvaluesarecoveredinthefollowingtable:

Table2.1.ConnectionProperties
Connection/AuthenticationuserTheusertoconnectasNopasswordThepasswordtousewhenconnectingNosocketFactoryThenameoftheclassthatthedrivershoulduseforcreatingsocketconnectionstotheserver.Thisclassmustimplementtheinterfacecom.mysql.jdbc.SocketFactoryandhavepublicno-argsconstructor.Nocom.mysql.jdbc.StandardSocketFactoryconnectTimeoutTimeoutforsocketconnect(inmilliseconds),with0beingnotimeout.OnlyworksonJDK-1.4ornewer.Defaultsto0.No0socketTimeoutTimeoutonnetworksocketoperations(0,thedefaultmeansnotimeout).No0useConfigsLoadthecomma-delimitedlistofconfigurationpropertiesbeforeparsingtheURLorapplyinguser-specifiedproperties.TheseconfigurationsareexplainedintheConfigurationsofthedocumentation.NointeractiveClientSettheCLIENT_INTERACTIVEflag,whichtellsMySQLtotimeoutconnectionsbasedonINTERACTIVE_TIMEOUTinsteadofWAIT_TIMEOUTNofalsepropertiesTransformAnimplementationofcom.mysql.jdbc.ConnectionPropertiesTransformthatthedriverwillusetomodifyURLpropertiespassedtothedriverbeforeattemptingaconnectionNouseCompressionUsezlibcompressionwhencommunicatingwiththeserver(true/false)?Defaultstofalse.NofalseHighAvailabilityandClusteringautoReconnectShouldthedrivertrytore-establishbadconnections?NofalseautoReconnectForPoolsUseareconnectionstrategyappropriateforconnectionpools(defaultstofalse)NofalsefailOverReadOnlyWhenfailingoverinautoReconnectmode,shouldtheconnectionbesettoread-only?NotruemaxReconnectsMaximumnumberofreconnectstoattemptifautoReconnectistrue,defaultis3.No3initialTimeoutIfautoReconnectisenabled,theinitialtimetowaitbetweenre-connectattempts(inseconds,defaultsto2).No2queriesBeforeRetryMasterNumberofqueriestoissuebeforefallingbacktomasterwhenfailedover(whenusingmulti-hostfailover).Whicheverconditionismetfirst,queriesBeforeRetryMasterorsecondsBeforeRetryMasterwillcauseanattempttobemadetoreconnecttothemaster.Defaultsto50.No50secondsBeforeRetryMasterHowlongshouldthedriverwait,whenfailedover,beforeattemptingtoreconnecttothemasterserver?Whicheverconditionismetfirst,queriesBeforeRetryMasterorsecondsBeforeRetryMasterwillcauseanattempttobemadetoreconnecttothemaster.Timeinseconds,defaultsto30No30SecurityallowMultiQueriesAllowtheuseof;todelimitmultiplequeriesduringonestatement(true/false,defaultstofalseNofalseuseSSLUseSSLwhencommunicatingwiththeserver(true/false),defaultstofalseNofalserequireSSLRequireSSLconnectionifuseSSL=true?(defaultstofalse).NofalseallowUrlInLocalInfileShouldthedriverallowURLsinLOADDATALOCALINFILEstatements?NofalseparanoidTakemeasurestopreventexposuresensitiveinformationinerrormessagesandcleardatastructuresholdingsensitivedatawhenpossible?(defaultstofalse)NofalsePerformanceExtensionsmetadataCacheSizeThenumberofqueriestocacheResultSetMetadataforifcacheResultSetMetaDataissettotrue(default50)No50prepStmtCacheSizeIfpreparedstatementcachingisenabled,howmanypreparedstatementsshouldbecached?No25prepStmtCacheSqlLimitIfpreparedstatementcachingisenabled,whatsthelargestSQLthedriverwillcachetheparsingfor?No256cacheCallableStmtsShouldthedrivercachetheparsingstageofCallableStatementsNofalsecachePrepStmtsShouldthedrivercachetheparsingstageofPreparedStatements?NofalsecacheResultSetMetadataShouldthedrivercacheResultSetMetaDataforStatementsandPreparedStatements?(Req.JDK-1.4+,true/false,defaultfalse)NofalsecacheServerConfigurationShouldthedrivercachetheresultsofSHOWVARIABLESandSHOWCOLLATIONonaper-URLbasis?NofalsedontUnpackBinaryResultsShouldthedriverdelayunpackingresultsfromserver-sidepreparedstatementsuntilthevaluesareaskedfor?NofalsedynamicCalendarsShouldthedriverretrievethedefaultcalendarwhenrequired,orcacheitperconnection/session?NofalseelideSetAutoCommitsIfusingMySQL-4.1ornewer,shouldthedriveronlyissuesetautocommit=nquerieswhentheserversstatedoesntmatchtherequestedstatebyConnection.setAutoCommit(boolean)?NofalseuseFastIntParsingUseinternalString->Integerconversionroutinestoavoidexcessiveobjectcreation?NotrueuseNewIOShouldthedriverusethejava.nio.*interfacesfornetworkcommunication(true/false),defaultstofalseNofalseuseReadAheadInputUsenewer,optimizednon-blocking,bufferedinputstreamwhenreadingfromtheserver?NotrueDebuging/ProfilingloggerThenameofaclassthatimplementscom.mysql.jdbc.log.Logthatwillbeusedtologmessagesto.(defaultiscom.mysql.jdbc.log.StandardLogger,whichlogstoSTDERR)Nocom.mysql.jdbc.log.StandardLoggerprofileSQLTracequeriesandtheirexecution/fetchtimestotheconfiguredlogger(true/false)defaultstofalseNofalseprofileSqlDeprecated,useprofileSQLinstead.Tracequeriesandtheirexecution/fetchtimesonSTDERR(true/false)defaultstofalseNomaxQuerySizeToLogControlsthemaximumlength/sizeofaquerythatwillgetloggedwhenprofilingortracingNo2048packetDebugBufferSizeThemaximumnumberofpacketstoretainwhenenablePacketDebugistrueNo20slowQueryThresholdMillisIflogSlowQueriesisenabled,howlongshouldaquery(inms)beforeitisloggedasslow?No2000useUsageAdvisorShouldthedriverissueusagewarningsadvisingproperandefficientusageofJDBCandMySQLConnector/Jtothelog(true/false,defaultstofalse)?NofalsedumpQueriesOnExceptionShouldthedriverdumpthecontentsofthequerysenttotheserverinthemessageforSQLExceptions?NofalseenablePacketDebugWhenenabled,aring-bufferofpacketDebugBufferSizepacketswillbekept,anddumpedwhenexceptionsarethrowninkeyareasinthedriverscodeNofalseexplainSlowQueriesIflogSlowQueriesisenabled,shouldthedriverautomaticallyissueanEXPLAINontheserverandsendtheresultstotheconfiguredlogataWARNlevel?NofalselogSlowQueriesShouldqueriesthattakelongerthanslowQueryThresholdMillisbelogged?NofalsetraceProtocolShouldtrace-levelnetworkprotocolbelogged?NofalseMiscellaneoususeUnicodeShouldthedriveruseUnicodecharacterencodingswhenhandlingstrings?Shouldonlybeusedwhenthedrivercantdeterminethecharactersetmapping,oryouaretryingtoforcethedrivertouseacharactersetthatMySQLeitherdoesntnativelysupport(suchasUTF-8),true/false,defaultstotrueNofalsecharacterEncodingIfuseUnicodeissettotrue,whatcharacterencodingshouldthedriverusewhendealingwithstrings?(defaultsistoautodetect)NocharacterSetResultsCharactersettotelltheservertoreturnresultsas.NoconnectionCollationIfset,tellstheservertousethiscollationviasetconnection_collationNoallowNanAndInfShouldthedriverallowNaNor+/-INFvaluesinPreparedStatement.setDouble()?NofalseautoDeserializeShouldthedriverautomaticallydetectandde-serializeobjectsstoredinBLOBfields?NofalsecapitalizeTypeNamesCapitalizetypenamesinDatabaseMetaData?(usuallyonlyusefulwhenusingWebObjects,true/false,defaultstofalse)NofalseclobberStreamingResultsThiswillcauseastreamingResultSettobeautomaticallyclosed,andanyoustandingdatastillstreamingfromtheservertobediscardedifanotherqueryisexecutedbeforeallthedatahasbeenreadfromtheserver.NofalsecontinueBatchOnErrorShouldthedrivercontinueprocessingbatchcommandsifonestatementfails.TheJDBCspecallowseitherway(defaultstotrue).NotrueemulateLocatorsN/ANofalseignoreNonTxTablesIgnorenon-transactionaltablewarningforrollback?(defaultstofalse).NofalsejdbcCompliantTruncationShouldthedriverthrowjava.sql.DataTruncationexceptionswhendataistruncatedasisrequiredbytheJDBCspecificationwhenconnectedtoaserverthatsupportswarnings(MySQL4.1.0andnewer)?NotruemaxRowsThemaximumnumberofrowstoreturn(0,thedefaultmeansreturnallrows).No-1pedanticFollowtheJDBCspectotheletter.NofalserelaxAutoCommitIftheversionofMySQLthedriverconnectstodoesnotsupporttransactions,stillallowcallstocommit(),rollback()andsetAutoCommit()(true/false,defaultstofalse)?NofalserollbackOnPooledCloseShouldthedriverissuearollback()whenthelogicalconnectioninapoolisclosed?NotrueserverTimezoneOverridedetection/mappingoftimezone.UsedwhentimezonefromserverdoesntmaptoJavatimezoneNostrictFloatingPointUsedonlyinolderversionsofcompliancetestNofalsestrictUpdatesShouldthedriverdostrictchecking(allprimarykeysselected)ofupdatableresultsets(true,false,defaultstotrue)?NotruetinyInt1isBitShouldthedrivertreatthedatatypeTINYINT(1)astheBITtype(becausetheserversilentlyconvertsBIT->TINYINT(1)whencreatingtables)?NotrueultraDevHackCreatePreparedStatementsforprepareCall()whenrequired,becauseUltraDevisbrokenandissuesaprepareCall()for_all_statements?(true/false,defaultstofalse)NofalseuseHostsInPrivilegesAdd@hostnametousersinDatabaseMetaData.getColumn/TablePrivileges()(true/false),defaultstotrue.NotrueuseOldUTF8BehaviorUsetheUTF-8behaviorthedriverdidwhencommunicatingwith4.0andolderserversNofalseuseOnlyServerErrorMessagesDontprependstandardSQLStateerrormessagestoerrormessagesreturnedbytheserver.NotrueuseServerPrepStmtsUseserver-sidepreparedstatementsiftheserversupportsthem?(defaultstotrue).NotrueuseSqlStateCodesUseSQLStandardstatecodesinsteadoflegacyX/Open/SQLstatecodes(true/false),defaultistrueNotrueuseStreamLengthsInPrepStmtsHonorstreamlengthparameterinPreparedStatement/ResultSet.setXXXStream()methodcalls(true/false,defaultstotrue)?NotrueuseTimezoneConverttime/datetypesbetweenclientandservertimezones(true/false,defaultstofalse)?NofalseuseUnbufferedInputDontuseBufferedInputStreamforreadingdatafromtheserverNotruezeroDateTimeBehaviorWhatshouldhappenwhenthedriverencountersDATETIMEvaluesthatarecomposedentirelyofzeroes(usedbyMySQLtorepresentinvaliddates)?Validvaluesareexception,roundandconvertToNull.Noexception
Connector/JalsosupportsaccesstoMySQLvianamedpipesonWindowsNT/2000/XPusingtheNamedPipeSocketFactoryasaplugin-socketfactoryviathesocketFactoryproperty.IfyoudontuseanamedPipePathproperty,thedefaultof.pipeMySQLwillbeused.IfyouusetheNamedPipeSocketFactory,thehostnameandportnumbervaluesintheJDBCurlwillbeignored.

AddingthefollowingpropertytoyourURLwillenabletheNamedPipeSocketFactory:

socketFactory=com.mysql.jdbc.NamedPipeSocketFactory

NamedpipesonlyworkwhenconnectingtoaMySQLserveronthesamephysicalmachineastheonetheJDBCdriverisbeingusedon.Insimpleperformancetests,itappearsthatnamedpipeaccessisbetween30%-50%fasterthanthestandardTCP/IPaccess.

Youcancreateyourownsocketfactoriesbyfollowingtheexamplecodeincom.mysql.jdbc.NamedPipeSocketFactory,orcom.mysql.jdbc.StandardSocketFactory.
posted2005-01-0412:54:00.0
还得说上一点,就java本质而言,是面相对象的,但是你有没有发现,java也不全是,比如说基本类型,int,那他就是整型而不是对象,转换类型是还得借助包装类。

兰色精灵 发表于 2015-1-21 16:26:53

是一种突破用户端机器环境和CPU

小女巫 发表于 2015-1-24 23:53:11

任职于太阳微系统的詹姆斯·高斯林等人于1990年代初开发Java语言的雏形,最初被命名为Oak,目标设置在家用电器等小型系统的程序语言

金色的骷髅 发表于 2015-2-1 10:29:44

你就该学一学Servlet了。Servlet就是服务器端小程序,他负责生成发送给客户端的HTML文件。JSP在执行时,也是先转换成Servlet再运行的。虽说JSP理论上可以完全取代Servlet,这也是SUN推出JSP的本意,可是Servlet用来控制流程跳转还是挺方便的,也令程序更清晰。接下来你应该学习一下Javabean了,可能你早就看不管JSP在HTML中嵌Java代码的混乱方式了,这种方式跟ASP又有什么区别呢?

小魔女 发表于 2015-2-7 03:35:22

象、泛型编程的特性,广泛应用于企业级Web应用开发和移动应用开发。

不帅 发表于 2015-2-11 08:42:26

是一种语言,用以产生「小应用程序(Applet(s))

蒙在股里 发表于 2015-2-16 23:11:42

Java 编程语言的风格十分接近C、C++语言。

简单生活 发表于 2015-3-11 13:58:03

如果你学过HTML,那么事情要好办的多,如果没有,那你快去补一补HTML基础吧。其实JSP中的Java语法也不多,它更象一个脚本语言,有点象ASP。

莫相离 发表于 2015-3-12 08:03:51

J2SE开发桌面应用软件比起 VC,VB,DEPHI这些传统开发语言来说,优势好象并不明显。J2ME对于初学者来说,好象又有点深奥,而且一般开发者很难有开发环境。

再见西城 发表于 2015-3-19 19:00:59

多重继承(以接口取代)等特性,增加了垃圾回收器功能用于回收不再被引用的对象所占据的内存空间,使得程序员不用再为内存管理而担忧。在 Java 1.5 版本中,Java 又引入了泛型编程(Generic Programming)、类型安全的枚举、不定长参数和自动装/拆箱等语言特性。

冷月葬花魂 发表于 2015-3-31 17:28:59

你快去找一份Java的编程工作来做吧(如果是在校学生可以去做兼职啊),在实践中提高自己,那才是最快的。不过你得祈祷在公司里碰到一个高手,而且他 还愿意不厌其烦地教你,这样好象有点难哦!还有一个办法就是读开放源码的程序了。我们知道开放源码大都出自高手,他们设计合理,考虑周到,再加上有广大的程序员参与,代码的价值自然是字字珠叽,铿锵有力(对不起,偶最近《金装四大才子》看多了)。

柔情似水 发表于 2015-4-3 21:51:12

是一种为 Internet发展的计算机语言

乐观 发表于 2015-4-14 18:57:44

一直感觉JAVA很大,很杂,找不到学习方向,前两天在网上找到了这篇文章,感觉不错,给没有方向的我指了一个方向,先不管对不对,做下来再说。

变相怪杰 发表于 2015-4-16 01:57:31

设计模式是高级程序员真正掌握面向对象核心思想的必修课。设计模式并不是一种具体"技术",它讲述的是思想,它不仅仅展示了接口或抽象类在实际案例中的灵活应用和智慧

小妖女 发表于 2015-4-21 22:20:27

在全球云计算和移动互联网的产业环境下,Java更具备了显著优势和广阔前景。

飘飘悠悠 发表于 2015-4-24 11:15:38

是一种将安全性(Security)列为第一优先考虑的语言

谁可相欹 发表于 2015-5-6 10:11:38

任职于太阳微系统的詹姆斯·高斯林等人于1990年代初开发Java语言的雏形,最初被命名为Oak,目标设置在家用电器等小型系统的程序语言

愤怒的大鸟 发表于 2015-5-10 00:44:45

任职于太阳微系统的詹姆斯·高斯林等人于1990年代初开发Java语言的雏形,最初被命名为Oak,目标设置在家用电器等小型系统的程序语言

再现理想 发表于 2015-5-10 23:51:56

学Java必读的两个开源程序就是Jive和Pet Store.。 Jive是国外一个非常著名的BBS程序,完全开放源码。论坛的设计采用了很多先进的技术,如Cache、用户认证、Filter、XML等,而且论坛完全屏蔽了对数据库的访问,可以很轻易的在不同数据库中移植。论坛还有方便的安装和管理程序,这是我们平时编程时容易忽略的一部份(中国程序员一般只注重编程的技术含量,却完全不考虑用户的感受,这就是我们与国外软件的差距所在)。
页: [1]
查看完整版本: JAVA网页编程之Driver Class Name and JDBC URL Forma...