Skip to content

Instantly share code, notes, and snippets.

@turbo
Created April 1, 2018 13:52
Show Gist options
  • Save turbo/45c988086f3646da510692729b879b0b to your computer and use it in GitHub Desktop.
Save turbo/45c988086f3646da510692729b879b0b to your computer and use it in GitHub Desktop.
using System;
using java.lang;
using java.sql;
namespace cdb2cs
{
internal static class Program
{
// Force type reference. Otherwise, the class will not be loaded.
// cdb2jdbc also doesn't offer an EmbeddedDriver, which would make this
// easier.
private static readonly Type foobar = typeof(com.bloomberg.comdb2.jdbc.Driver);
public static void Main()
{
Class.forName("com.bloomberg.comdb2.jdbc.Driver");
var conn = DriverManager.getConnection("jdbc:comdb2://localhost/testdb");
var stmt = conn.createStatement();
var rs = stmt.executeQuery("SELECT 1+1 as \"math\"");
while (rs.next())
{
Console.WriteLine($"Result is {rs.getInt(1)}\n");
}
rs.close();
stmt.close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment