🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] ## golang ``` package main import ( "database/sql" "fmt" "log" "os" _ "github.com/VoltDB/voltdb-client-go/voltdbclient" ) func main() { // If using a version of VoltDB server prior to 5.2, then // set the version of the wire protocol to 0. The default // value 1, indicates a server version of 5.2 or later. // voltdbclient.ProtocolVersion = 0 db, err := sql.Open("voltdb", "localhost:21212") if err != nil { log.Fatal(err) } defer db.Close() err = db.Ping() if err != nil { log.Fatal(err) } rows, err := db.Query("HELLOWORLD.select", "French") if err != nil { log.Fatal(err) } printRows(rows) // with prepared statement stmt, err := db.Prepare("select * from HELLOWORLD where dialect = ?") if err != nil { log.Fatal(err) } rows, err = stmt.Query("French") if err != nil { log.Fatal(err) } printRows(rows) } func printRows(rows *sql.Rows) { for rows.Next() { var hello string var world string var dialect string err := rows.Scan(&hello, &world, &dialect) if err != nil { fmt.Println(err) break } fmt.Printf("SUCCESS: %s %s %s\n", hello, world, dialect) } } ```