Browse Source

改成从配置文件中获取

xyxie 1 year ago
parent
commit
17e539a2d7
3 changed files with 5 additions and 4 deletions
  1. 1 0
      config/config.go
  2. 1 1
      core/run_server.go
  3. 3 3
      init_serve/oracle_jy.go

+ 1 - 0
config/config.go

@@ -59,4 +59,5 @@ type OracleJY struct {
 	Conn     string `mapstructure:"conn" json:"conn" yaml:"conn" description:"服务链接地址"`
 	Account  string `mapstructure:"account" json:"account" yaml:"account" description:"oracle数据库账号"`
 	Password string `mapstructure:"password" json:"password" yaml:"password" description:"oracle数据库密码"`
+	LibDir   string `mapstructure:"lib_dir" json:"lib_dir" yaml:"lib_dir" description:"oracle数据库组件"`
 }

+ 1 - 1
core/run_server.go

@@ -21,7 +21,7 @@ func RunServe() {
 
 	if global.CONFIG.OracleJY.Account != "" {
 		//初始化oracle
-		//	init_serve.OracleJy()
+		init_serve.OracleJy()
 	}
 	// 启动任务
 	init_serve.InitTask()

+ 3 - 3
init_serve/oracle_jy.go

@@ -10,7 +10,7 @@ import (
 
 func OracleJy() {
 	conf := global.CONFIG.OracleJY
-	err := connOracle(conf.Account, conf.Password, conf.Conn)
+	err := connOracle(conf.Account, conf.Password, conf.Conn, conf.LibDir)
 	if err != nil {
 		fmt.Println("oracle 数据库连接失败")
 		global.LOG.Info("oracle 数据库连接失败,Err: " + err.Error())
@@ -18,7 +18,7 @@ func OracleJy() {
 	}
 }
 
-func connOracle(username, pwd, connectionStr string) (err error) {
+func connOracle(username, pwd, connectionStr, libDir string) (err error) {
 	var P godror.ConnectionParams
 	P.Username, P.Password = username, godror.NewPassword(pwd)
 	P.ConnectString = connectionStr
@@ -26,7 +26,7 @@ func connOracle(username, pwd, connectionStr string) (err error) {
 		P.SetSessionParamOnInit("NLS_NUMERIC_CHARACTERS", ",.")
 		P.SetSessionParamOnInit("NLS_LANGUAGE", "FRENCH")*/
 	P.Timezone = time.Local
-	P.LibDir = "/home/soft/oracle/instantclient_21_11"
+	P.LibDir = libDir
 	oracleJyDb := sql.OpenDB(godror.NewConnector(P))
 	err = oracleJyDb.Ping()
 	if err != nil {