java odbc foxpro - java

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.

Related

c# connect to sql via jdbc

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.

Can multiple users connect to a Microsoft Access database at the same time using Java?

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.

jdbc odbc connectivity

am a newbie to java. I want to create a table in MYSQL and insert images into it.I have to write code in java to insert the images. can anyone tell me how to give connectivity between mySQL and java code. Can u suggest some materials for jdbc odbc connectivity.
Don't even think about mentioning ODBC when you're talking Java. JDBC-ODBC bridges were useful once, when we didn't have proper drivers but they should be considered a crime against humanity nowadays :-)
What you want is a type-4 (pure Java) JDBC driver and the "official" one is MySQL Connector/J.
That page also has links to a short JDBC Basics course and a more in-depth one, for your education.

Selecting a JDBC Driver

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.

what databases can be used with java?

I am doing an undergrad final project, and need to justify my choice of MySQL for the database element of my project. Truth is, it's the only one I can really use, and hence I went for it.
What other database systems could I have used? Any advantages and disadvantages of these over MySQL?
In fact, you can use every database which is accessible through a JDBC driver. Almost all self-respected RDBMS vendors provides a fullworthy JDBC driver for download at their homepage. Just Google "[vendorname] jdbc driver download" to find it. Here's an overview:
MySQL JDBC driver
PostgreSQL JDBC driver (note: older versions doesn't support generated keys).
Oracle JDBC driver (note: older versions doesn't support generated keys).
MSSQL JDBC driver (or performancewise better, the jTDS JDBC driver)
DB2 JDBC driver is hard to find in IBM's online forest, but it's usually already included in the /java folder of the DB2 installation.
This way you can use the JDBC API transparently to access either of the databases.
As to which database to choose, just look at the features, robustness, performance, etc the RDBMS provides and the budget you have -if it isn't freeware. I myself tend to prefer PostgreSQL.
Instead of a fullfledged database server, you can also consider an embedded Javabased database, such as Sun Oracle JavaDB, Apache Derby, HSQLDB or SQLite, each which are of course accessible through the JDBC API the usual way.
You can use any relational database that has a JDBC driver. These would include PostgreSQL, Hypersonic SQL, MySQL, SQLLite on the free side and Oracle, MS SQL Server, and others on the paid side.
The biggest advantage accrued to MySQL in your case is that it's free and you know it. That's enough to make it suitable for what you want to accomplish.
You could have used pretty much ANY database. MSSQL, SQLite, Postgre, Oracle or [put your choice here]
There's a driver for pretty much any database to integrate with Java. This is a great place to find out all the DB's java support, as well as how to integrate
Hope this helps
Have a look at the list of vendors who have endorsed the JDBC API maintained by Sun. Also see the list of third-party JDBC technology-enabled drivers which are currently shipping.
You mentioned MySQL and database. For the case you are free to usa a non RDBMS you can check db4o.
Advantage: pure OO/Java persistence.
Many have said this already, but pretty much any database will work. Consider including the top 5 (based on rankings, popularity) in your writeup.

Categories