如何在Linux Dockerfile中安装HDBODBC驱动程序?

huangapple go评论57阅读模式
英文:

How to install HDBODBC Drivers in a Linux Dockerfile?

问题

我正在尝试从 Linux Dockerfile 连接到 SAP HANA 数据库。目前在 Dockerfile 中安装 HDBODBC 驱动程序或找到相关资源方面遇到了困难。

  1. 我该如何在 Dockerfile 中安装 HDBODBC 驱动程序?
  2. 我是否需要一个 odbc.ini 文件,或者仅使用连接字符串就足够了?

注意:我熟悉在没有 Docker 的情况下以及在 Windows 上使用连接字符串连接到 SAP HANA。

Dockerfile 当前内容:

FROM --platform=linux/amd64 node:16.13.0

WORKDIR /usr/src/app
COPY package*.json ./

RUN npm install

RUN apt-get update && apt-get install -y unixodbc unixodbc-dev
RUN apt-get install odbcinst

COPY . .
EXPOSE 8080
CMD ["node", "src/index.js"]

当我仅使用连接字符串运行我的代码时,我看到:

[Error: [odbc] 连接到数据库时出错] {
   odbcErrors: [
     {
       state: '01000',
       code: 0,
       message: "[unixODBC][驱动程序管理器]无法打开库 'HDBODBC':文件未找到"
     }
   ]
 }

这让我认为我没有安装驱动程序。

英文:

I am trying to connect to a SAP HANA database from a Linux Dockerfile. Currently having trouble with installing the HDBODBC Driver in the Dockerfile or finding resources for it.

  1. How can I install HDBODBC Driver in a Dockerfile?
  2. Do I need an odbc.ini file or is using a connection string sufficient?

Note: I am familiar with connecting to SAP HANA without docker and on Windows using a connection string

Dockerfile currently:

FROM --platform=linux/amd64 node:16.13.0

WORKDIR /usr/src/app
COPY package*.json ./

RUN npm install

RUN apt-get update && apt-get install -y unixodbc unixodbc-dev
RUN apt-get install odbcinst

COPY . .
EXPOSE 8080
CMD ["node", "src/index.js"]

When I run my code with just the connection string I am seeing:

[Error: [odbc] Error connecting to the database] {
   odbcErrors: [
     {
       state: '01000',
       code: 0,
       message: "[unixODBC][Driver Manager]Can't open lib 'HDBODBC' : file not found"
     }
   ]
 }

Which makes me think I don't have the driver installed

答案1

得分: 1

你需要 HANA 客户端。请前往:https://tools.hana.ondemand.com/#hanatools

英文:

You need the HANA Client. Try here: https://tools.hana.ondemand.com/#hanatools

huangapple
  • 本文由 发表于 2023年7月28日 02:33:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/76782543.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定