I have a program in c# and need to connect to SQL via JDBC. I read that JDBC works with java and since I need to use it from C#, I found out that there is jni4net that bridges between the two.
I can't seem to find any samples or tutorials on how to do so. Any help will be appreciated. I have read and tried using jni4net, but I couldn't find any sample connecting to a database.
JDBC stands for Java DataBase Connectivity, which means it is for Java (or other languages that can run on the Java Virtual Machine). C# is a different language with its own runtime. Although it may be possible to access Java from C#, doing so for database connections would probably be really cumbersome and slow.
Instead you should look for an ADO.net database provider for your database system(s). Most database systems have one.
You may use the robbiblubber.org JDBC Extension Libaray to connect to a database via JDBC from .NET. Of cource, if there is a native driver for ADO.NET, you should use that.
Related
The question is pretty self-explanatory, but below is some more info about the situation:
I am building a Java program that will be replacing a program that consists of an Excel user interface with an Access database. The Excel program connects to the Access database and communicates with VBA. But, so far there has only ever been one user at a time. Now that the program is due to expand, we need many users to be able to write to any table at the same time.
Access allows multiple users to connect at once, of course. This is not possible in HSQLDB, which is what prompted the question. Obviously, this is better accomplished with a server, but the plan is to build the program using the current database and then accomplish the transition to a server later.
Thanks in advance
In order to support multiple concurrent users (processes) writing to an Access database you must use the Access Database Engine. The options to do that from a Java application are:
Use Java's own JDBC-ODBC Bridge and the Access ODBC driver. (Note that the JDBC-ODBC Bridge was removed from Java 8.)
Use a third-party JDBC-ODBC Bridge and the Access ODBC driver.
Use a third-party JDBC driver that works with the Access Database Engine (if such a thing exists).
Note especially that the UCanAccess JDBC driver does not use the Access Database Engine and therefore does not support multiple concurrent users (processes) writing to the Access database.
You can do it. I have a similar application that I use. In version 1.8 of Java, the ODBC bridge was removed, so you'll have to look into using a separate library to connect, assuming you are using 1.8 or above. For me, it's way slower, but it does work. check out
Removal of JDBC ODBC bridge in java 8
I use "Ucanaccess" for my program, which is one of the suggestions in that question.
I am trying to connect to a local .mdb file using Java 8. So far I have used UCanAccess's libraries but not all features are supported.
In Java 8 "JDBC/ODBC was scrapped"... So my question is:
What is the new method to connect to .mdb files (without UCanAccess)?
If you really don't want to use UCanAccess then you'll probably have to buy a third-party library
to replace the JDBC-ODBC Bridge that was removed from Java 8, or
to provide direct JDBC connectivity to the Access database.
However, as Marco indicates in his comment to the question, there could very well be UCanAccess (or HSQLDB) workarounds for your "feature not supported" issues if you care to give us a hint as to what they are.
I am attempting to build some java apps that use a FoxPro database that is part of a large Visual FoxPro product. I have been able to read the data using a jdbc-odbc bridge. While I had to search long and hard to find out how to accomplish that task, what I haven't been able to find out is if I can safely insert/delete/edit the tables. I don't know if the index files are used by the jdbc-odbc libraries.
On a related note, does anyone know if you use MS SqlServer to set up a link to the foxpro data will make the FoxPro data "act" like a real relational db, or if the functionality doing things that way is the same as using the odbc solution.
I'm not replacing the current Visual FoxPro product, just trying to add some functionality, and I don't want to break the existing product.
Thanks.
I would imagine the JDBC-ODBC bridge handles indexes transparently, it wouldn't be much use otherwise.
You might be better looking at StelsDBF or Hxtt's native JDBC drivers.
Visual FoxPro is already a relational database. Not sure what you would achieve via the MSSQL approach.
I'm trying to select a JDBC driver for an application I'm building and I've found lots of drivers, but I can't seem to narrow the selection down to one. The driver I select should have the following features:
Free for commercial use
Easy to install (eg. single jar file, no drivers to install)
Easy to use (well documented)
No database server required
Multi-user / Network support
What JDBC database drivers would you suggest?
So far I've considered TinySQL and SQLite.
The database is not very large think maybe 10k records.
The JDBC driver depends on the database you want to use. Some free databases include:
Derby (small, lightweight, comes with Java 1.6)
MySQL (bigger, lots of features)
PostgreSQL (bigger, lots of features)
I'm sure there are others.
When you install the database, the documentation will tell you where to get the JDBC driver.
Unless you have specific requirements, I would have suggested that you use MySQL, it is free and very popular. Also, it is very easy to use through JDBC. However, I then saw your comment:
I want to use a JDBC driver so if I
change databases the database will
have the same interface. Right now I
need a database that meets the above
requirements.
The problem is that, as far as I know, JDBC alone isn't that flexible. With JDBC you basically pass strings to and fro the application and the database engine. If you want something that allows you to change the database but doesn't impact the way that your application and database communicate, you should consider and ORM tool like Hibernate.
The OP asked for 'no database server'. That means that there are two options in common use: Derby and HSQLDB that integrate well into Java.
Is it possible to access a local HSQL database from Ruby as well as from Java? (separately of course, not concurrent) The Ruby SQL toolkit called Sequel, for example, claims to have "adapters" for JDBC, so I think the answer is yes, yes? =)
If the answer is "kind of" or something, is there a better RDBMS that would allow straightforward access from both languages? Ideally I would want support for server-side DB's as well...
Yes, provided that you use the JRuby implementation of Ruby. I've used Sequel with H2 on JRuby - IIRC I just installed Sequel and the h2 gem on JRuby and then specified the database connection as normal.
There is a rubyforge project for an HSQLDB driver. I haven't used it, but it looks like what you're after.
I am not a Ruby programmer so not sure about Ruby. But if there is a JDBC adapter for that database then you should be able to access the database.
If you're using JRuby, you can use all JDBC adapters.