Skip to content

Instantly share code, notes, and snippets.

@disq
Created June 19, 2017 08:51
Show Gist options
  • Save disq/e6903684629077bb80afe40c5bcfb14f to your computer and use it in GitHub Desktop.
Save disq/e6903684629077bb80afe40c5bcfb14f to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"database/sql"
"time"
_ "github.com/VoltDB/voltdb-client-go/voltdbclient"
)
func main() {
db, err := sql.Open("voltdb", "localhost:21212") // <-- insert hostname here
if err != nil {
panic(err)
}
db.SetConnMaxLifetime(1 * time.Second) // <-- This will leak connections every second or so, observe with "netstat -an|grep 21212"
fmt.Println("Starting query...")
for {
stmt, err := db.Prepare("SELECT CURRENT_TIMESTAMP() FROM SOME_TABLE_IN_VOLTDB LIMIT 1") // <-- insert table name here
if err != nil {
panic(err)
}
var dest string
err = stmt.QueryRow().Scan(&dest)
if err != nil {
panic(err)
}
fmt.Println(dest)
time.Sleep(500 * time.Millisecond)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment