Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of Database driver Class DriverManager.getConnection () in jdbc

Shulou Source: shulou.com Published: 2022-06-03 11:01:30 11月15日 Update

This article mainly shows you the "jdbc database driver class DriverManager.getConnection () example analysis", the content is easy to understand, clear, hope to help you solve the doubt, the following let the editor lead you to study and learn "database driver class DriverManager.getConnection () in jdbc sample analysis" this article.

DriverManager.getConnection () Oracle8/8i/9i database (thin schema)

Class.forName (oracle.jdbc.driver.OracleDriver) .newInstance ()

Stringurl= "jdbc:oracle:thin:@localhost:1521:orcl"

/ / orcl is the SID of the database

Stringuser= "test"

Stringpassword= "test"

Connectionconn=DriverManager.getConnection (url,user,password)

DriverManager.getConnection () DB2 database

Class.forName (com.ibm.db2.jdbc.app.DB2Driver) .newInstance ()

Stringurl= "jdbc:db2://localhost:5000/sample"

/ / sample is your database name

Stringuser= "admin"

Stringpassword= ""

Connectionconn=DriverManager.getConnection (url,user,password)

SqlServer7.0/2000 database (three jar packages: msbase.jar,mssqlserver.jar,msutil.jar)

Class.forName (com.microsoft.jdbc.sqlserver.SQLServerDriver) .newInstance ()

Stringurl= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb"

/ / mydb is the database

Stringuser= "sa"

Stringpassword= ""

Connectionconn=DriverManager.getConnection (url,user,password)

Note: when a jar package (sqljdbc4.jar), it should look like this, get rid of "microsoft"

Class.forName (com.jdbc.sqlserver.SQLServerDriver) .newInstance ()

Stringurl= "jdbc:sqlserver://localhost:1433;DatabaseName=mydb"

The above is all the contents of the article "sample Analysis of the database-driven class DriverManager.getConnection () in jdbc". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Data database example analysis driver content article learning help three time easy to understand more organization pattern knowledge editing industry information information channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information macOS vpn Docker OPPO Reno