4、原生jdbc链接数据库常用资源名

原生jdbc链接数据库要素:
#MySql:
String url="jdbc:mysql://localhost:3306/数据库名";
String name="root"; //数据库用户名
String password="123456"; //数据库用户密码
Class.forName("com.mysql.jdbc.Driver") ; //加载MySQL驱动
Connection conn = DriverManager.getConnection(url,name,password); //连接数据库

#Oracle:
String url="jdbc:oracle:thin:@localhost:1521:数据库名";
String name="数据库用户名"; //数据库用户名
String password="数据库用户密码"; //数据库用户密码
Class.forName("oracle.jdbc.driver.OracleDriver"); //加载oracle驱动
Connection conn = DriverManager.getConnection(url,name,password); //连接数据库

#SqlServer:
String url="jdbc:sqlserver://localhost:1433;DatabaseName=数据库名"; //数据库地址
Sring name="数据库用户名"; //数据库用户名
String password="数据库用户密码"; //数据库用户密码
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); //加载Sql Server驱动
Connection conn = DriverManager.getConnection(url,name,password); //连接数据库

 

Spring Boot项目链接数据库要素:
#MySql:
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://192.168.1.1:3306/hserp?characterEncoding=utf-8&allowMultiQueries=true
spring.datasource.username=root
spring.datasource.password=root

#H2
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:~/test;AUTO_SERVER=TRUE
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.show-sql=true

posted @ 2019-04-17 11:48  五柳先生柳三变  阅读(272)  评论(0编辑  收藏  举报