How to form connection between HSQLDB and C# .net ? I have already looked at SharpHSQL and H2Sharp but not able to connect the HSQLDB.
Basic steps:
Download IKVM.NET and HyperSQL (=HSQLDB) driver.
Convert HSQLDB Java driver to .NET DLL using IKVM.NET to create a hsqldb.dll
Add compile time dependencies to your C# project:
using System;
using System.Configuration;
namespace HyperSQL
{
class Program
{
readonly static string CONNECTION_STRING = ConfigurationManager.ConnectionStrings["HyperSQL"].ConnectionString;
const string SQL = "SELECT * FROM customer";
static void Main(string[] args)
{
java.sql.DriverManager.registerDriver(new org.hsqldb.jdbcDriver());
using (java.sql.Connection conn = java.sql.DriverManager.getConnection(CONNECTION_STRING))
{
java.sql.PreparedStatement ps = conn.prepareStatement(SQL);
using (java.sql.ResultSet rs = ps.executeQuery())
{
while (rs.next())
{
Console.WriteLine($"ID={rs.getInt("id")}");
Console.WriteLine($"NAME={rs.getString("name")}");
Console.WriteLine($"AGE={rs.getInt("age")}");
Console.WriteLine($"ADDRESS={rs.getString("address")}");
Console.WriteLine($"SALARY={rs.getInt("salary")}");
Console.WriteLine("------------------");
}
}
}
Console.ReadLine();
}
}
}
Here my detailed tutorial how to connect to HyperSQL from C#