数据库

位置:IT落伍者 >> 数据库 >> 浏览文章

常用数据库 JDBC 连接写法全攻略


发布日期:2022年06月04日
 
常用数据库 JDBC 连接写法全攻略

常用数据库JDBC连接写法

MySQL()mmmysqlbinjar

ClassforName( orggjtmmmysqlDriver );

cn = DriverManagergetConnection( jdbc:mysql://MyDbComputerNameOrIP:/myDatabaseName sUsr sPwd );

PostgreSQL()pgjdbcjar

ClassforName( orgpostgresqlDriver );

cn = DriverManagergetConnection( jdbc:postgresql://MyDbComputerNameOrIP/myDatabaseName sUsr sPwd );

Oracle()classeszip

ClassforName( oraclejdbcdriverOracleDriver );

cn = DriverManagergetConnection( jdbcracle:thin:@MyDbComputerNameOrIP::ORCL sUsr sPwd );

Sybase()jconnjar

ClassforName( comsybasejdbcjdbcSybDriver );

cn = DriverManagergetConnection( jdbc:sybase:Tds:MyDbComputerNameOrIP: sUsr sPwd );

//(DefaultUsername/Password: dba/sql)

Microsoft SQLServer()

ClassforName( netsourceforgejtdsjdbcDriver );

cn = DriverManagergetConnection( jdbc:jtds:sqlserver://MyDbComputerNameOrIP:/master sUsr sPwd );

Microsoft SQLServer()

ClassforName( commicrosoftjdbcsqlserverSQLServerDriver );

cn = DriverManagergetConnection( jdbc:microsoft:sqlserver://MyDbComputerNameOrIP:;databaseName=master sUsr sPwd );

ODBC

ClassforName( sunjdbcodbcJdbcOdbcDriver );

Connection cn = DriverManagergetConnection( jdbcdbc: + sDsn sUsr sPwd );

DB

ClassforName(DBDriver);

String url=jdbc:db://:/SAMPLE

cn = DriverManagergetConnection( url sUsr sPwd );

上一篇:在Oracle10g Release 2中的Autotrace

下一篇:Oracle中如何获得当前数据库的SCN值