Example #1
0
// Sets the ODBC version for the environment
func SetODBCVersion(version ODBCVersion) {
	switch version {
	case ODBCVersion_3:
		ret := odbc.SQLSetEnvAttr(envHandle, odbc.SQL_ATTR_ODBC_VERSION, odbc.SQL_OV_ODBC3, 0)
		if isError(ret) {
			panic(errorEnvironment(envHandle))
		}
		break
	case ODBCVersion_380:
		ret := odbc.SQLSetEnvAttr(envHandle, odbc.SQL_ATTR_ODBC_VERSION, odbc.SQL_OV_ODBC3_80, 0)
		if isError(ret) {
			panic(errorEnvironment(envHandle))
		}
		break
	}
}
Example #2
0
// Allocates shared environment
func init() {

	// Set environment handle for connection pooling
	ret := odbc.SQLSetEnvAttr(envHandle, odbc.SQL_ATTR_CONNECTION_POOLING, odbc.SQL_CP_ONE_PER_DRIVER, 0)
	if isError(ret) {
		panic(errorEnvironment(envHandle))
	}

	// Allocate the environment handle
	ret = odbc.SQLAllocHandle(odbc.SQL_HANDLE_ENV, 0, &envHandle)
	if isError(ret) {
		panic(errorEnvironment(envHandle))
	}

	// Set the environment handle to use ODBC v3
	ret = odbc.SQLSetEnvAttr(envHandle, odbc.SQL_ATTR_ODBC_VERSION, odbc.SQL_OV_ODBC3, 0)
	if isError(ret) {
		panic(errorEnvironment(envHandle))
	}

	// Register with the SQL package
	d := &lodbcDriver{}
	sql.Register("lodbc", d)
}