多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[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) } } ```