All Projects → jmrobles → h2go

jmrobles / h2go

Licence: other
Apache H2 Go SQL Driver

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to h2go

Hive Jdbc Uber Jar
Hive JDBC "uber" or "standalone" jar based on the latest Apache Hive version
Stars: ✭ 188 (+437.14%)
Mutual labels:  driver, apache
test-data-loader
A Groovy DSL for creating test data via JPA
Stars: ✭ 12 (-65.71%)
Mutual labels:  h2, h2-database
rql-scala
RethinkDB Scala Driver
Stars: ✭ 13 (-62.86%)
Mutual labels:  driver
generic-linked-in-driver
A generic non-blocking linked-in driver for interfacing Erlang and C
Stars: ✭ 46 (+31.43%)
Mutual labels:  driver
wiasane
Scanner Access Now Easy - WIA Driver
Stars: ✭ 109 (+211.43%)
Mutual labels:  driver
Driver.NET
Lightweight and flexible library to load and communicate with kernel drivers on Windows.
Stars: ✭ 59 (+68.57%)
Mutual labels:  driver
WindowsIoTEverywhere
Images & drivers to get WIndows 10 IoT running on off-the-shelf tablets, mini-pcs, and various computers.
Stars: ✭ 23 (-34.29%)
Mutual labels:  driver
airflow-prometheus-exporter
Export Airflow metrics (from mysql) in prometheus format
Stars: ✭ 25 (-28.57%)
Mutual labels:  apache
abb robot driver
The new ROS driver for ABB robots
Stars: ✭ 55 (+57.14%)
Mutual labels:  driver
silverbox
Guide describing how to setup compact, silent and energy-efficient GNU/Linux home server
Stars: ✭ 42 (+20%)
Mutual labels:  apache
qpid-dispatch
Mirror of Apache Qpid Dispatch
Stars: ✭ 62 (+77.14%)
Mutual labels:  apache
dxx
Windows Kernel Driver with C++ runtime
Stars: ✭ 128 (+265.71%)
Mutual labels:  driver
OpenDriver2Tools
Driver 1 and Driver 2 tools
Stars: ✭ 25 (-28.57%)
Mutual labels:  driver
PoC-CVE-2021-41773
No description or website provided.
Stars: ✭ 39 (+11.43%)
Mutual labels:  apache
jota-cert-checker
Check SSL certificate expiration date of a list of sites.
Stars: ✭ 45 (+28.57%)
Mutual labels:  apache
tutorial lamp virtualbox
Tutorial para instalação da VirtualBox, Linux, Apache, MySQL e PHP.
Stars: ✭ 31 (-11.43%)
Mutual labels:  apache
rtl88x2BU WiFi linux v5.2.4.1 22719 COEX20170518-4444.20170613
rtl88x2bu driver updated for modern kernels.
Stars: ✭ 26 (-25.71%)
Mutual labels:  driver
openwhisk-runtime-dotnet
Apache OpenWhisk Runtime .Net supports Apache OpenWhisk functions written in .Net languages
Stars: ✭ 23 (-34.29%)
Mutual labels:  apache
windows-process-monitor
A demo solution to illustrate approaches on getting information about processes and block/allow their start
Stars: ✭ 89 (+154.29%)
Mutual labels:  driver
modules
Mesos modules examples and open source modules outside of the Apache Mesos source tree.
Stars: ✭ 26 (-25.71%)
Mutual labels:  apache

Apache H2 Database Go Driver

This driver is VERY experimental state

NOT use for production yet

Introduction

Apache H2 Database is a very-low footprint database with in-memory capabilities.

It's written in Java and it's fully ACID compliant.

You can use H2 as embedded database or via TCP/IP.

It has interfaces for Postgres protocol and native TCP server.

Motivation

Until now, using H2 in your Go projects could only be done through the Postgres driver.

This approach has several cons. The poor error messagens or not being able to use native data types are some of them.

This pure Go driver uses the native TCP interface.

Pre-requesites

In "contrib" folder you can find the scripts to download and launch the H2 database server. You need to have any Java Runtime installed.

cd contrib
./downloadH2.sh
./runStandalone.sh

Usage

First make sure the H2 server is running in TCP server mode. You can launch using the runStandalone.sh or with a command similar to the following:

java -classpath h2.jar org.h2.tools.Server -tcp -tcpAllowOthers -ifNotExists

This starts the server at the defaulr port (9092)

The following example connect to H2 and creates an in-memory database.

package main

import (
	"database/sql"
	"log"
	_ "github.com/jmrobles/h2go"
)

func main() {
	conn, err := sql.Open("h2", "h2://sa@localhost/testdb?mem=true")
	if err != nil {
		log.Fatalf("Can't connet to H2 Database: %s", err)
	}
    err = conn.Ping()
    if err != nil {
        log.Fatalf("Can't ping to H2 Database: %s", err)
    }
    log.Printf("H2 Database connected")
    conn.Close()
}

In the folder examples you can find more examples.

Connection string

In the connection string you must specify:

  • Database driver: h2 literal
  • Username (optional)
  • Password (optinal)
  • Host: format (:)?
  • Database name
  • Other connection options

Options

You can use the following options:

  • mem=(true|false): to use in-memory or in-disk database
  • logging=(none|info|debug|error|warn|panic|trace): the common logging level

Parameters

For the use of parameters in SQL statement you need to use the ? placeholder symbol.

For example:

    conn.Exec("INSERT INTO employees VALUES (?,?,?)", name, age, salary)

Data types

The following H2 datatypes are implemented:

H2 Data type Go mapping
String string
StringIgnoreCase string
StringFixed string
Bool bool
Short int16
Int int32
Long int64
Float float32
Double float64
Byte byte
Bytes []byte
Time time.Time
Time with timezone time.Time
Date time.Time
Timestamp time.Time
Timestamp with timezone time.Time

H2 Supported version

This driver supports H2 database version 1.4.200 or above.

ToDo

  • Rest of native data types (UUID, JSON, Decimal, ...)
  • NamedValue interface
  • Multiple result sets
  • Improve context usage (timeouts, ...)
  • Submit your issue

Contributors

jmrobles

Pull Requests are welcome

License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].