Click here to Skip to main content
15,891,908 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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)
Posted
Updated 22-May-19 4:16am
Comments
Maciej Los 11-Mar-18 7:04am    
What have you tried? Show your code!

1 solution

Yes, it's possible. Check this: H2 (DBMS) - Wikipedia[^]. At the bottom of page, you'll find a link to h2sharp project:
Quote:
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());
                 }
             }
        }
    }
} 



 
Share this answer
 
Comments
[no name] 14-Mar-18 8:37am    
Thank You, but this is not answering my question.
You are using JDBC but I want to use ODBC with an embedded H2 database because I have an application that uses embedded H2 as database system.

Thanks
Maciej Los 14-Mar-18 10:36am    
Seems you didn't follow the link of Wikipedia. There you'll find discussion about PostgreSQL ODBC driver for H2 databases.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900