Beispiel #1
0
func (conn *Connection) ClientInfo() (string, string, string, *ODBCError) {
	var info_len C.SQLSMALLINT
	p := make([]byte, INFO_BUFFER_LEN)
	ret := C.SQLGetInfo(C.SQLHDBC(conn.Dbc), C.SQL_DRIVER_NAME, C.SQLPOINTER(unsafe.Pointer(&p[0])), INFO_BUFFER_LEN, &info_len)
	if !Success(ret) {
		err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc, int(ret))
		debugPrint("SQLGetInfo ERROR=", err)
		return "", "", "", err
	}
	drv_name := string(p[0:info_len])
	ret = C.SQLGetInfo(C.SQLHDBC(conn.Dbc), C.SQL_DRIVER_ODBC_VER, C.SQLPOINTER(unsafe.Pointer(&p[0])), INFO_BUFFER_LEN, &info_len)
	if !Success(ret) {
		err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc, int(ret))
		debugPrint("SQLGetInfo ERROR=", err)
		return "", "", "", err
	}
	drv_odbc_ver := string(p[0:info_len])
	ret = C.SQLGetInfo(C.SQLHDBC(conn.Dbc), C.SQL_DRIVER_VER, C.SQLPOINTER(unsafe.Pointer(&p[0])), INFO_BUFFER_LEN, &info_len)
	if !Success(ret) {
		err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc, int(ret))
		debugPrint("SQLGetInfo ERROR=", err)
		return "", "", "", err
	}
	drv_ver := string(p[0:info_len])
	return drv_name, drv_odbc_ver, drv_ver, nil
}
Beispiel #2
0
func (conn *Connection) ServerInfo() (string, string, string, *ODBCError) {
	var info_len C.SQLSMALLINT
	p := make([]byte, INFO_BUFFER_LEN)
	ret := C.SQLGetInfo(C.SQLHDBC(conn.Dbc), C.SQL_DATABASE_NAME, C.SQLPOINTER(unsafe.Pointer(&p[0])), INFO_BUFFER_LEN, &info_len)
	if !Success(ret) {
		err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc, int(ret))
		debugPrint("SQLGetInfo ERROR=", err)
		return "", "", "", err
	}
	db := string(p[0:info_len])
	ret = C.SQLGetInfo(C.SQLHDBC(conn.Dbc), C.SQL_DBMS_VER, C.SQLPOINTER(unsafe.Pointer(&p[0])), INFO_BUFFER_LEN, &info_len)
	if !Success(ret) {
		err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc, int(ret))
		debugPrint("SQLGetInfo ERROR=", err)
		return db, "", "", err
	}
	ver := string(p[0:info_len])
	ret = C.SQLGetInfo(C.SQLHDBC(conn.Dbc), C.SQL_SERVER_NAME, C.SQLPOINTER(unsafe.Pointer(&p[0])), INFO_BUFFER_LEN, &info_len)
	if !Success(ret) {
		err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc, int(ret))
		debugPrint("SQLGetInfo ERROR=", err)
		return db, ver, "", err
	}
	server := string(p[0:info_len])
	return db, ver, server, nil
}