当前位置:网站首页>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
边栏推荐
- 【踩坑】nacos注册一直连接localhost:8848,no available server
- ESP32-ULP协处理器低功耗模式RTC GPIO中断唤醒
- channel. Detailed explanation of queuedeclare parameters
- 模拟卷Leetcode【普通】1567. 乘积为正数的最长子数组长度
- 注解@ConfigurationProperties的三种使用场景
- Required String parameter ‘XXX‘ is not present
- [南京大学]-[软件分析]课程学习笔记(一)-introduction
- 指针进阶,字符串函数
- 使用AGC重签名服务前后渠道号信息异常分析
- Required String parameter ‘XXX‘ is not present
猜你喜欢
Greenplum 6.x reinitialization
A bug using module project in idea
Greenplum6.x搭建_环境配置
【MySQL】数据库进阶之触发器内容详解
Category of IP address
Why choose cloud native database
[Yugong series] February 2022 U3D full stack class 007 - production and setting skybox resources
leetcode134. gas station
Nanjing commercial housing sales enabled electronic contracts, and Junzi sign assisted in the online signing and filing of housing transactions
Other 7 features of TCP [sliding window mechanism ▲]
随机推荐
模拟卷Leetcode【普通】1609. 奇偶树
Appeler l'interface du moteur de création du service multimédia de jeu Huawei renvoie le Code d'erreur 1002, le message d'erreur: les paramètres sont l'erreur
Calf problem
MAC OSX php dyld: Library not loaded: /usr/local/xxxx. dylib
【微信小程序:缓存操作】
ncs成都新电面试经验
Greenplum6.x重新初始化
Greenplum6.x监控软件搭建
xray的简单使用
Greenplum 6.x build_ install
Tronapi-波场接口-源码无加密-可二开--附接口文档-基于ThinkPHP5封装-作者详细指导-2022年7月6日-新手快速上手-可无缝升级tp6版本
平台化,强链补链的一个支点
数据分析方法论与前人经验总结2【笔记干货】
Goldbach conjecture C language
更改当前文件夹及文件夹下文件日期shell脚本
Shell script for changing the current folder and the file date under the folder
NCS Chengdu Xindian interview experience
Markdown editor Use of MD plug-in
Problems encountered in the use of go micro
如何在图片的目标中添加目标的mask