当前位置:网站首页>Several common database connection methods
Several common database connection methods
2022-07-07 08:53:00 【Please Sit Down】
MySQL:
String Driver="com.mysql.jdbc.Driver"; // The driver
String URL="jdbc:mysql://localhost:3306/db_name"; // Connected URL,db_name Name the database
String Username="username"; // user name
String Password="password"; // password
Class.forName(Driver);
Connection con=DriverManager.getConnection(URL,Username,Password);
Oracle:
String Driver="oracle.jdbc.driver.OracleDriver"; // How to connect to the database
String URL="jdbc:oracle:thin:@loaclhost:1521:orcl"; //orcl For database SID
String Username="username"; // user name
String Password="password"; // password
Class.forName(Driver) ; // Load database driver
Connection con=DriverManager.getConnection(URL,Username,Password);
DB2:
String Driver="com.ibm.dbjdbc.app.DBDriver"; // Connection has DB2 Client's Provider example
//String Driver="com.ibm.dbjdbc.net.DBDriver"; // Connection does not have DB2 Client's Provider example
String URL="jdbc:db2://localhost:5000/db_name"; //db_name Name the database
String Username="username"; // user name
String Password="password"; // password
Class.forName(Driver) ;
PostgreSQL:
String Driver="org.postgresql.Driver"; // How to connect to the database
String URL="jdbc:postgresql://localhost/db_name"; //db_name Name the database
String Username="username"; // user name
String Password="password"; // password
Class.forName(Driver) ;
Connection con=DriverManager.getConnection(URL,Username,Password);
Microsoft SQL Server :
String Driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"; // Connect SQL Database method
String URL="jdbc:sqlserver://localhost:1433;DatabaseName=db_name"; //db_name Name the database
String Username="username"; // user name
String Password="password"; // password
Class.forName(Driver).new Instance(); // Load data to drive
边栏推荐
- A bug using module project in idea
- 調用華為遊戲多媒體服務的創建引擎接口返回錯誤碼1002,錯誤信息:the params is error
- Frequently Asked Coding Problems
- 测试踩坑 - 当已有接口(或数据库表中)新增字段时,都需要注意哪些测试点?
- mysql分区讲解及操作语句
- How to integrate app linking services in harmonyos applications
- PPT模板、素材下载网站(纯干货,建议收藏)
- Calling the creation engine interface of Huawei game multimedia service returns error code 1002, error message: the params is error
- Count sort (diagram)
- [Yugong series] February 2022 U3D full stack class 008 - build a galaxy scene
猜你喜欢
随机推荐
About using CDN based on Kangle and EP panel
Other 7 features of TCP [sliding window mechanism ▲]
Three usage scenarios of annotation @configurationproperties
说一个软件创业项目,有谁愿意投资的吗?
注解@ConfigurationProperties的三种使用场景
Selenium automation integration, eight years of testing experience, soft test engineer, an article to teach you
C language for calculating the product of two matrices
LeetCode 736. Lisp 语法解析
Greenplum6.x搭建_安装
Count sort (diagram)
Markdown编辑器Editor.md插件的使用
Unity Shader入门精要初级篇(一)-- 基础光照笔记
opencv之图像分割
Why choose cloud native database
详解华为应用市场2022年逐步减少32位包体上架应用和策略
MAC OSX php dyld: Library not loaded: /usr/local/xxxx. dylib
ncs成都新电面试经验
Redis fault handling "can't save in background: fork: cannot allocate memory“
Category of IP address
ncs成都新電面試經驗