JDBC.NET icon indicating copy to clipboard operation
JDBC.NET copied to clipboard

JdbcConnection.Open() throwing exception

Open diogosilva96 opened this issue 4 years ago • 1 comments

So I was trying to estabilish a Jdbc connection on .NET through this library. Whenever I try to load my Jdbc driver, the following error occurs: Grpc.Core.RpcException: 'Status(StatusCode=Internal, Detail="org/apache/log4j/Logger")'. This occurs when the JdbcConnection bridge is being created when calling JdbcConnection.Open(). You can find my code below: var driverPath = $"{Path.GetDirectoryName(typeof(Program).Assembly.Location)}\\MyJdbcDriver.jar"; var builder = new JdbcConnectionStringBuilder { DriverPath = driverPath, DriverClass = "com.example.jdbc.MyDriver", JdbcUrl = "jdbc:MyDriver:HOST='localhost';PORT='8087';UID='admin;PWD='123';ACC='Admin'" }; var connection = new JdbcConnection(builder); connection.Open(); var command = connection.CreateCommand("SELECT * FROM Users;"); var reader = command.ExecuteReader();

I ensured that the driver path contains the jdbc driver. I also tried this using ConnectionString property instead of the JdbcUrl and with relative or absolute paths of the jdbc driver, but didn't work either. I think this might have to do with how I setup my connection string or either the DriverPath/DriverClass is not setup correctly.

Note: I was able to estabilish this connection on Java, using this exact driver and connection string but no luck on .NET side with this library.

Any ideas why I might be getting this error?

Thanks.

diogosilva96 avatar Feb 19 '21 15:02 diogosilva96

JdbcUrl = "jdbc:MyDriver:HOST='localhost';PORT='8087';UID='admin;PWD='123';ACC='Admin'" };

If im reading that correctly, you are missing a single quote ( ' ) after UID='admin (;PWD=).

But as a future feature, it would also be nice to have the exception surfaced to .net, so we could see this immediately

tcables avatar Nov 28 '23 20:11 tcables