JAVA数据库连接速查


1、Oracle8/8i/9i数据库(thin模式)

Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl"; //orcl为数据库的SID
String user="test";
String password="test";
Connection conn= DriverManager.getConnection(url,user,password);

 2、DB2数据库

Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance();
String url="jdbc:db2://localhost:5000/sample"; //sample为你的数据库名
String user="admin";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);

3、Sql Server7.0/2000数据库

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb";
//mydb为数据库
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);

Microsoft SQL Server (jTDS driver)
jdbc:jtds:sqlserver://localhost:1433/myDB;tds=8.0;lastupdatecount=true
//myDB为数据库名
jar包:jtds.jar

 4、Sybase数据库

Class.forName("com.sybase.jdbc.SybDriver").newInstance();
String url =" jdbc:sybase:Tds:localhost:5007/myDB";//myDB为你的数据库名
Properties sysProps = System.getProperties();
SysProps.put("user","userid");
SysProps.put("password","user_password");
Connection conn= DriverManager.getConnection(url, SysProps);


5、Informix数据库

Class.forName("com.informix.jdbc.IfxDriver").newInstance();
String url = "jdbc:informix-sqli://123.45.67.89:1533/myDB:INFORMIXSERVER=myserver;
user=testuser;password=testpassword"; //myDB为数据库名
Connection conn= DriverManager.getConnection(url);

 6、MySQL数据库

Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost/myDB?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1"
//myDB为数据库名
Connection conn= DriverManager.getConnection(url);

7、PostgreSQL数据库

Class.forName("org.postgresql.Driver").newInstance();
String url ="jdbc:postgresql://localhost/myDB" //myDB为数据库名
String user="myuser";
String password="mypassword";
Connection conn= DriverManager.getConnection(url,user,password);

8、access数据库直连用ODBC的

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
String url="jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ="+application.getRealPath("/Data/ReportDemo.mdb");
Connection conn = DriverManager.getConnection(url,"","");
Statement stmtNew=conn.createStatement() ;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Java函数速查,方便使用的Java类库查询手册 chm版,可查询以下四个包的所有类库内容:   Package com.ms.wfc.app   Application类   CharacterSet类   Clipboard类   DataFormats类   DataFormats.Formats类   DataObject类   IDataObject界面   IMessageFilter界面   Locale类   Locale.CalendarType类   Locale.DateFormatOrder类   Locale.Languages类   Locale.LeadingZeros类   Locale.MeasurementSystem类   Locale.NegativeNumberMode类   Locale.OptionalCalendarType类 Locale.PositiveCurrencyMode类   Locale.Sort类   Locale.SubLanguages类   Message类   MethodInvoker代理   Registry类   RegistryKey类   SendKeys类   SpecialFolder类   SystemInformation类   SystemInformation.ArrangeDirection类   SystemInformation.ArrangeStartingPosition类   ThreadExceptionDialog类   ThreadExceptionEvent类   ThreadExceptionEventHandler代理   Time类   Timer类   Version类   Window类   Package com.ms.wfc.data.ui   Column类   ColumnEditingEvent类   ColumnEditingEventHandler代理   ColumnEvent类   ColumnEventHandler代理   ColumnResizeEvent类   ColumnResizeEventHandler代理   ColumnUpdatingEvent类   ColumnUpdatingEventHandler代理   DataBinder类   DataBinding类   DataGrid类   DataNavigator类   DataSource类   EnterAction类   ErrorEvent类   ErrorEventHandler代理   GridLineStyle类   PositionChangeEvent类   PositionChangeEventHandler代理   Scrollbars类   TabAction类      Package com.ms.wfc.html   DhAlignment类   DhBaseContainer类   DhBorderInfo类   DhBorders类   DhBorderStyle类   DhBreak类   DhBrowser类   DhBulletedList类   DhButton类   DhCantAddElementException类   DhCantModifyElementException类   DhCell类   DhCheckBox类   DhComboBox类   DhComponentWrapper类   DhCursor类   DhDialogInfo类   DhDocument类   DhEdit类   DhElement类   DhElementExistsInDocumentException类   DhElementNotFoundException类   DhEnumeration类   DhEventInfo类   DhForm类   DhHorizontalRule类   DhHotSpot类   DhHotSpotShapes类   DhHTMLGenerator类   DhHyperlink类   DhImage类   DhInlineFrame类   DhInsertOptions类   DhJumpPoint类   DhLinkTarget类   DhListBox类   DhListType类   DhMargins类   DhMarginWidthI
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值