spring boot怎么連接多種數(shù)據(jù)庫
spring boot怎么連接多種數(shù)據(jù)庫?
RISEBY
2019-08-21 12:10:13
TA貢獻1807條經(jīng)驗 獲得超9個贊
--在WEB.config配置下面的節(jié)點,connectionstring寫的是連接數(shù)據(jù)庫的字符串datasource是填寫的數(shù)據(jù)庫,initialcatalog是連接的數(shù)據(jù)庫名稱,user id是連接數(shù)據(jù)的賬戶名,password是賬戶的密碼
<connectionStrings>
<add name="connstring" connectionString="Data Source=.\HH;Initial Catalog=stu;User ID=sa;Password=123;"/>
</connectionStrings>
--在web應用層獲取這段數(shù)據(jù)庫連接字符串的語句是
ConfigurationManager.ConnectionStrings["connstring"].ToString()
舉報