.NET5 Linux 环境通过ODBC连Impala 报System.Data.Odbc.OdbcException(0x80131937):ERROR[H]错误

环境配置过程:

1 unixODBC依赖包的安装

  • 检查是否安装unixODBC包
$ rpm -qa |grep -i unixodbc
  • 安装unixODBC依赖包
$ sudo yum -y install unixODBC unixODBC-devel

1 unixODBC依赖包的安装

  • 检查是否安装unixODBC包
$ rpm -qa |grep -i unixodbc
  • 安装unixODBC依赖包
$ sudo yum -y install unixODBC unixODBC-devel

配置ODBC DataSource

--------------------------------------------------------------------------------------------------------------------------------

配置后 程序Open链接时 报System.Data.Odbc.OdbcException(0x80131937):ERROR[H]异常

更改Cloudera ODBC Driver for Impala驱动配置文件的编码配置:增加 

DriverManagerEncoding=UTF-16

如下:

[Driver]

## - Note that this default DriverManagerEncoding of UTF-32 is for iODBC.
## - unixODBC uses UTF-16 by default.
## - If unixODBC was compiled with -DSQL_WCHART_CONVERT, then UTF-32 is the correct value.
##   Execute 'odbc_config --cflags' to determine if you need UTF-32 or UTF-16 on unixODBC
## - SimbaDM can be used with UTF-8 or UTF-16.
##   The DriverUnicodeEncoding setting will cause SimbaDM to run in UTF-8 when set to 2 or UTF-16 when set to 1.

DriverManagerEncoding=UTF-16
## UTF-32
ErrorMessagesPath=/opt/cloudera/impalaodbc/ErrorMessages/
LogLevel=0
LogPath=
SwapFilePath=/tmp


## - Uncomment the ODBCInstLib corresponding to the Driver Manager being used.
## - Note that the path to your ODBC Driver Manager must be specified in LD_LIBRARY_PATH (LIBPATH for AIX).
## - Note that AIX has a different format for specifying its shared libraries.

# Generic ODBCInstLib
#   iODBC
#ODBCInstLib=libiodbcinst.so

#   SimbaDM / unixODBC
#ODBCInstLib=libodbcinst.so

# AIX specific ODBCInstLib
#   iODBC
#ODBCInstLib=libiodbcinst.a(libiodbcinst.so.2)

#   SimbaDM
#ODBCInstLib=libodbcinst.a(odbcinst.so)

#   unixODBC
ODBCInstLib=libodbcinst.a(libodbcinst.so.1)

However, the System.Data.Odbc should give us an explicit error message, instead of ERROR [H] [unixODBC][.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
根据提供的引用内容,这个错误信息表明在尝试建立JDBC连接时出现了问题。具体来说,它指出了一个嵌套的SQLException,该异常的原因是无法找到名为“com.cloudera.impala.jdbc.Driver”的驱动程序。这通常是由于缺少相应的JDBC驱动程序或驱动程序未正确配置所致。 解决此问题的步骤如下: 1. 确保已正确安装并配置了所需的JDBC驱动程序。在这种情况下,需要确保已正确安装Cloudera Impala JDBC驱动程序。 2. 确保在代码中正确指定了JDBC驱动程序的位置。这通常涉及到在代码中指定正确的JDBC URL和驱动程序类名。 3. 确保数据库服务器正在运行,并且可以从您的应用程序服务器上的网络访问该服务器。 以下是一个Java代码示例,演示如何建立JDBC连接并执行查询: ```java import java.sql.*; public class JdbcExample { public static void main(String[] args) { Connection conn = null; Statement stmt = null; ResultSet rs = null; try { // Register JDBC driver Class.forName("com.cloudera.impala.jdbc.Driver"); // Open a connection System.out.println("Connecting to database..."); conn = DriverManager.getConnection("jdbc:impala://localhost:21050/default", "<username>", "<password>"); // Execute a query System.out.println("Creating statement..."); stmt = conn.createStatement(); String sql; sql = "SELECT id, name, age FROM employees"; rs = stmt.executeQuery(sql); // Extract data from result set while (rs.next()) { // Retrieve by column name int id = rs.getInt("id"); String name = rs.getString("name"); int age = rs.getInt("age"); // Display values System.out.print("ID: " + id); System.out.print(", Name: " + name); System.out.println(", Age: " + age); } // Clean-up environment rs.close(); stmt.close(); conn.close(); } catch (SQLException se) { // Handle errors for JDBC se.printStackTrace(); } catch (Exception e) { // Handle errors for Class.forName e.printStackTrace(); } finally { // Finally block used to close resources try { if (stmt != null) stmt.close(); } catch (SQLException se2) { } // nothing we can do try { if (conn != null) conn.close(); } catch (SQLException se) { se.printStackTrace(); } // end finally try } // end try } } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值