Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report