鏁版嵁搴撻┍鍔ㄨ繛鎺ュ瓧绗︿覆

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了鏁版嵁搴撻┍鍔ㄨ繛鎺ュ瓧绗︿覆相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/http' title='http'>http   灏辨槸   suse   鏈嶅姟   test   classes   computer   bdr   

1. mysql(http://www.mysql.com)mm.mysql-2.0.2-bin.jar
Class.forName( "org.gjt.mm.mysql.Driver" );
cn = DriverManager.getConnection(
"jdbc:mysql://MyDbComputerNameOrIP:3306/myDatabaseName", sUsr, sPwd );


2. PostgreSQL(http://www.de.postgresql.org)pgjdbc2.jar
Class.forName( "org.postgresql.Driver" );
cn = DriverManager.getConnection(
"jdbc:postgresql://MyDbComputerNameOrIP/myDatabaseName",
sUsr, sPwd );
3. Oracle(http://www.oracle.com/ip/deploy/database/oracle9i/)classes12.zip

Class.forName( "oracle.jdbc.driver.OracleDriver" );
cn = DriverManager.getConnection( "jdbc:oracle:thin:@MyDbComputerNameOrIP:1521:ORCL", sUsr, sPwd );


4. Sybase(http://jtds.sourceforge.net)jconn2.jar
Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" );
cn = DriverManager.getConnection(
"jdbc:sybase:Tds:MyDbComputerNameOrIP:2638", sUsr, sPwd );
// (Default-Username/Password: "dba"/"sql")


5. Microsoft SQLServer(http://jtds.sourceforge.net)
Class.forName( "net.sourceforge.jtds.jdbc.Driver" );
cn = DriverManager.getConnection(
"jdbc:jtds:sqlserver://MyDbComputerNameOrIP:1433/master", sUsr, sPwd );


6. Microsoft SQLServer(http://www.microsoft.com)
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" );
cn = DriverManager.getConnection( "jdbc:microsoft:sqlserver://MyDbComputerNameOrIP:1433;databaseName=master", sUsr, sPwd );


7. ODBC
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
Connection cn = DriverManager.getConnection( "jdbc:odbc:" + sDsn, sUsr, sPwd );


8.DB2
Class.forName("Com.ibm.db2.jdbc.net.DB2Driver");
String url="jdbc:db2://192.9.200.108:6789/SAMPLE"
cn = DriverManager.getConnection( url, sUsr, sPwd );

-----------------------------------------

mysql鎴戠敤浠ヤ笅杩炵粨锛?br /> mySQL:Connector/J 3.2
http://dev.mysql.com/downloads/connector/j/3.2.html

Class.forName("com.mysql.jdbc.Driver").newInstance();

Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3307/test?user=monty&password=greatsqldb");

闂鏄紝鎴戝湪linux涓嬪氨鏄笉鎴愬姛锛佸緱鍒伴敊璇細Connetion refused.
鏌ヤ簡寰堝璧勬枡锛岃鏄痬ySQL鐨勯厤缃棶棰?浣嗘槸鐢╩ySQLClient鍙互杩炵粨銆傞偅涔堥敊璇埌搴曟槸浠€涔堝憿锛?/p>

缁堜簬鍦╨inux锛坰use)涓嬬敤JDeveloper杩為€氫簡mySQL.
鐜版妸鑷繁璧拌繃寮矾寰楀埌缁忛獙鍛婅瘔澶у锛屽笇鏈涘鏈夌被浼奸棶棰樼殑浜烘湁甯姪锛?br /> 1銆佹渶閲嶈鐨勬枃浠舵槸锛?etc/my.cnf锛?
閲岄潰澶у娉ㄦ剰鏈嶅姟鍣ㄥ惎鍔ㄧ殑绔彛鍙凤紙port),缃戠粶鏀寔锛坣etwork
supporting)鏄渶瑕佹牴鎹嚜宸辩殑鎯呭喌鏇存敼鐨勩€傛瘮濡傝鎴戠殑mysql鐢ㄧ殑鏄?307绔彛锛岃€屼笉鏄己鐪佺殑3306锛屽氨闇€瑕佹洿鏀硅椤广€傛敞閲婃帀skip
network,鍚﹀垯鍒板ご鐮磋娴佷篃杩炰笉鍚屻€?br /> 2銆侀渶瑕佸埌mzsql鐨勭綉绔欏幓涓嬭浇mysqlconnector.鐒跺悗灏嗚鎯虫斁鍦?JAVA_HOME/jre/lib/ext.鍚﹀垯绋嬪簭浼氬憡璇変綘com.mysql.jdbc.Driver鎵句笉鍒般€?br /> 3銆佷笉瑕佸繕浜嗙粰浣犺鐢ㄧ殑鐢ㄦ埛鍦╩ysql涓巿鏉冦€?br /> 鍢庡槑銆傘€傘€傘€?/p>

以上是关于鏁版嵁搴撻┍鍔ㄨ繛鎺ュ瓧绗︿覆的主要内容,如果未能解决你的问题,请参考以下文章

闈㈣瘯瀹橈細鏁版嵁搴撹繛鎺ユ睜涓轰粈涔堥兘瑕佺敤Threadlocal鍛紵

MyCat瀹炵幇鏁版嵁搴撲笌鏁版嵁搴撲箣闂寸殑璇诲啓鍒嗙

Mysql鏁版嵁搴撳熀纭€鐭ヨ瘑

鍒濊瘑mybatis

鏁版嵁搴撳垎鐗?Sharding)