import (
    "database/sql"
    "encoding/json"
    "fmt"
    _ "github.com/godror/godror"
    "gorm.io/gorm"
    "log"
    "testing"
)

func TestOracleT(t *testing.T) {
    db, err := sql.Open("godror", `user="ADMIN" password="123456"
    connectString="(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1521)(host=adb.ap-seoul-1.oraclecloud.com))(connect_data=(service_name=3434343434.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)))"
    `)
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println("网络连接成功")
    defer db.Close()
    //db.Exec("CREATE TABLE TEST2 (name VARCHAR2(20))")
    res, err := db.Exec("INSERT INTO TEST2 VALUES ('tom')")
    if err != nil {
        fmt.Println(err)
    }
    fmt.Println(res.RowsAffected())
    fmt.Println(res.LastInsertId())
}

发表回复

您的电子邮箱地址不会被公开。

Captcha Code