golang连接开启kerberos的phoenix query server服务端

phoenix query server

其他语言可以连接phoenix 可以通过 phoenix query server 连接

calcite-avatica-go

  • 新建项目Phoenix-Golang项目
  • go.mod
module Phoenix-Golang
go 1.15
require github.com/apache/calcite-avatica-go/v5 v5.0.0 // indirect
  • example
package main

import (
	"database/sql"
	"fmt"
)
import _ "github.com/apache/calcite-avatica-go/v5"

func main() {
	db, _ := sql.Open("avatica", "http://xxx:8765/SYSTEM"+
		"?authentication=SPNEGO"+
		"&krb5Conf=/etc/krb5.conf"+
		"&serialization=PROTOBUF"+
		"&principal=xx/xx@HADOOP.COM"+
		"&keytab=/Users/xx/keytab/xx.keytab")
	rows, err := db.Query("SELECT TABLE_SCHEM,TABLE_NAME FROM CATALOG")
	if err != nil {
		panic(err)
	}
	defer rows.Close()

	var (
		TABLE_SCHEM  string
		TABLE_NAME string
	)

	for rows.Next() {

		err := rows.Scan(&TABLE_SCHEM, &TABLE_NAME)
		if err != nil {
			errors := fmt.Sprintln("err: ", err)
			print(errors)
		}

		result := fmt.Sprintln("result: ", TABLE_SCHEM, TABLE_NAME)
		print(result)
	}
}
上一篇:聊聊源码贡献这件大事


下一篇:Tomcat初学时遇到的问题