forked from sijms/go-ora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
connect_option.go
78 lines (73 loc) · 1.76 KB
/
connect_option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package network
import (
"strconv"
"github.com/sijms/go-ora/trace"
)
type ClientData struct {
ProgramPath string
ProgramName string
UserName string
HostName string
DriverName string
PID int
}
type ConnectionOption struct {
Port int
TransportConnectTo int
SSLVersion string
WalletDict string
TransportDataUnitSize uint16
SessionDataUnitSize uint16
Protocol string
Host string
UserID string
//IP string
SID string
//Addr string
//Server string
ServiceName string
InstanceName string
DomainName string
DBName string
ClientData ClientData
//InAddrAny bool
Tracer trace.Tracer
connData string
PrefetchRows int
}
func (op *ConnectionOption) ConnectionData() string {
if len(op.connData) > 0 {
return op.connData
}
FulCid := "(CID=(PROGRAM=" + op.ClientData.ProgramPath + ")(HOST=" + op.ClientData.HostName + ")(USER=" + op.ClientData.UserName + "))"
address := "(ADDRESS=(PROTOCOL=" + op.Protocol + ")(HOST=" + op.Host + ")(PORT=" + strconv.Itoa(op.Port) + "))"
result := "(CONNECT_DATA="
if op.SID != "" {
result += "(SID=" + op.SID + ")"
} else {
result += "(SERVICE_NAME=" + op.ServiceName + ")"
}
//if op.ServiceName != "" {
//
//} else {
// if op.SID != "" {
//
// }
//}
if op.InstanceName != "" {
result += "(INSTANCE_NAME=" + op.InstanceName + ")"
}
result += FulCid
return "(DESCRIPTION=" + address + result + "))"
}
//func NewConnectionOption(conStr *go_ora.ConnectionString) *ConnectionOption {
//
//}
//func NewConnectionOption() *ConnectionOption {
// return &ConnectionOption{
// Port: 0xFFFF,
// TransportConnectTo: 0xFFFF,
// TransportDataUnitSize: 0xFFFF,
// SessionDataUnitSize: 0xFFFF,
// }
//}