可以通过ODBC连接到嵌入式H2数据库吗? [英] It's possible to connect to an embedded H2 database via ODBC?

查看:117
本文介绍了可以通过ODBC连接到嵌入式H2数据库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过ODBC连接到嵌入式H2数据库



我尝试过:



我试过PostgreSQL ODBC驱动程序,但我不知道具体参数(特别是服务器)

I'm trying to connect to an embedded H2 database via ODBC

What I have tried:

I have tried the PostgreSQL ODBC driver but I don't know the specific parameters (Specially, the Server)

推荐答案

是, 这是可能的。检查一下: H2(DBMS) - 维基百科 [ ^ ]。在页面底部,你会找到一个指向h2sharp项目的链接:

Yes, it's possible. Check this: H2 (DBMS) - Wikipedia[^]. At the bottom of page, you'll find a link to h2sharp project:
Quote:

这个项目包装了生成的库包含实现ADO.Net接口的类,以便在.Net项目中使用。



示例代码 [ ^ ]:

This project wraps the resulting library with classes that implement the ADO.Net interface to allow for easy use in .Net projects.

Sample code[^]:

using System;
using System.Data.H2;

namespace H2SharpExample
{
    public class Program
    {
        static void Main(string[] args)
        {
             using (H2Connection connection = new H2Connection("jdbc:h2:~/test", "sa", ""))
             {
                 connection.Open();
                 using (H2Command command = connection.CreateCommand())
                 {
                     command.CommandText = "Select 'hello world'";
                     Console.WriteLine(command.ExecuteScalar());
                 }
             }
        }
    }
} 











这篇关于可以通过ODBC连接到嵌入式H2数据库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆