connect Ms Access to java - java

I extracted data from excel using poi api. Now I want to store the data in access please clarify

To the point, you just want to "convert" Excel to MSAccess using Java code? Here are the steps:
1) Extract data from Excel into Java objects (List, String, Number, Javabean, etc).
2) Insert the data in flavor of those Java objects into MSAccess.
That's basically all. For 1) you can use under each the Apache POI as you already found out. For 2) you can use the JDBC. I think your problem is more that you don't understand what JDBC is and how to work with it. In that case you may find the Sun's JDBC tutorial useful. Good luck.

You need something like JetProxy -- a JDBC driver interfacing to Jet (the internal name of Microsoft Access's own quasi-relational sort-of-SQL DB engine). There are other products much in the same vein, but I have no personal experience to help suggest which product is best for your purposes -- just try a few!-)

You can either use the commercial JDBC drivers by HXTT or the JDBC-ODBC bridge by Sun

Related

VBA connection to Java

I have an Excel with some macros. The data is currently sourced manually. In order to automate the report, I need to source the data directly from Oracle database. Unfortunately, this cannot be done, as it is a production database and passwords cannot be shared with anyone.
The next best possible approach is to connect via the Java layer. How can I connect VBA with a Java service?
Any conceptual starting points will also be appreciated.
There is a very nice API from Apache called POI for processing Microsoft documents. http://poi.apache.org/
The other approach is to use OLEDB driver for Excel which will allow you to read data from Excel exactly as you will do from any database using JDBC.
Interop between different technologies likes this is commonly achieved with a combination http and xml.
It's a long time since I saw this done so the technologies might be out of date but you can create a ADO record set from XML.
Excel can make a http call to a Java server that returns the xml. This xml can then be used to create a record set for Excel to consume just as if that record set were obtained directly from the database.

Is it possible to save persistent objects to the file system

I'd like to save persistent objects to the file system using Hibernate without the need for a SQL database.
Is this possible?
Hibernate works on top of JDBC, so all you need is a JDBC driver and a matching Hibernate dialect.
However, JDBC is basically an abstraction of SQL, so whatever you use is going to look, walk and quack like an SQL database - you might as well use one and spare yourself a lot of headaches. Besides, any such solution is going to be comparable in size and complexity to lighweight Java DBs like Derby.
Of course if you don't insist absolutely on using Hibernate, there are many other options.
It appears that it might technically be possible if you use a JDBC plaintext driver; however I haven't seen any opensource ones which provide write access; the one I found on sourceforge is read-only.
You already have an entity model, I suppose you do not want to lose this nor the relationships contained within it. An entity model is directed to be translated to a relational database.
Hibernate and any other JPA provider (EclipseLink) translate this entity model to SQL. They use a JDBC driver to provide a connection to an SQL database. This, you need to keep as well.
The correct question to ask is: does anybody know an embedded Java SQL database, one that you can start from within Java? There are plenty of those, mentioned in this topic:
HyperSQL: stores the result in an SQL clear-text file, readily imported into any other database
H2: uses binary files, low JAR file size
Derby: uses binary files
Ashpool: stores data in an XML-structured file
I have used HyperSQL on one project for small data, and Apache Derby for a project with huge databases (2Gb and more). Apache Derby performs better on these huge databases.
I don't know exactaly your need, but maybe it's one of below:
1 - If your need is just run away from SQL, you can use a NoSQL database.
Hibernate suports it through Hibernate OGM ( http://www.hibernate.org/subprojects/ogm ).
There are some DBs like Cassandra, MongoDB, CouchDB, Hadoop... You have some suggestions Here
.
2 - Now, if you want not to use a database server (with a service process running always), you can use Apache Derby. It's a DB just like any other SQL, but no need of a server. It uses a singular file to keep data. You can easily transport all database with your program.
Take a look: http://db.apache.org/derby/
3 - If you really want some text plain file, you can do like Michael Borgwardt said. But I don't know if Hibernate would be a good idea in this case.
Both H2 and HyperSQL support embedded mode (running inside your JVM instead of in a separate server) and saving to local file(s); these are still SQL databases, but with Hibernate there's not many other options.
Well, since the question is still opened and the OP said he's opened to new approaches/suggestions, here's mine (a little late but ok).
Do you know Prevayler? It's a Java Prevalence implementation which keep all of your business objects in RAM and mantain Snapshots/Changelogs in the File System, this way it's extremely fast and reliable, since if there's any crash, it'll restore it's last state and reapply every change to it.
Also, it's really easy to setup and run in your app.
Ofcourse this is possible, You can simply use file io features of Java, following steps are required:-
Create a File Object
2.Create an object of FileInputStream (though there are ways which use other Classes)
Wrap this object in a Buffer object or simply inside a java.util.Scanner.
use specific write functions of the object created in previous step.
Note that your object must implement Serializable interface. See following link,

Import custom protocol into MS Excel / Access

I have a standalone Java application capable of replaying a time series of data records. Communication with the server is performed using a bespoke binary wire protocol over TCP/IP.
We have a requirement to be able to easily import data records from this application into MS Excel / Access and I am interested in the recommended way to do this.
One idea we're exploring is to write a web "wrapper" service (also in Java) that will communicate with the underlying server and then translate the binary data into a more friendly text format for consumption by Excel / Access. However, the drawback here is that we lose any type information associated with each field in a given record.
I've briefly looked into writing custom ODBC / OleDB drivers but this seems complex and is probably overkill for what we're trying to achieve.
Can anyone recommend any other approaches?
How about xlloop? http://xlloop.sourceforge.net/
Uses an Excel plugin to connect to a function server, where you can create your own functions.
You may connect with an Access Database via the JDBC/ODBC Bridge driver.
From your previous comments I assume that you need to serve dynamic/changing data. If that is the case then take maybe the IRtdServer interface and this article referring to Excel. Its a COM Interface so you probably will need something like Com4j

how many DBMS are supported by Java and which one is the best for storing XMLs?

I am working with Jsbs and want to select a DBMS for my application that require a native XML database. Can you people guide me?
1) how many DBMS are supported by Java (is it true almost all DBMS are supported by java?)
2) Which one will be the best selection for XML storage and retrieval?
Thanks in advance.
Here is a list of JDBC Drivers and the DBs they work for. Probably every database out there has a JDBC driver.
As far as supporting XML it depends if you want to be able to do queries against the XML or not. Most modern DBMSs support XML to some degree. Do you have one you are already using, or that you are recommended to use ?
1) Yes, there are JDBC drivers for all the major DBMS (Oracle, MySQL, Postgres, DB2...) and also some interesting java DBMS like HSQL
2) As far as I know Oracle, DB2, PostgreSQL (and probably MySQL) all have XML column types
It is not obvious to me that you need anything more than support for Blobs or Clobs to implement simple XML storage and retrieval. You'd only need special XML support if you needed to perform queries against the data contained in the XML.
What you are talking about is an "XML enabled" RDBMS. Depending on your actual requirements, you may also want to look into native XML databases (NXDs). There is even a standard Java API (XQJ) for querying NXDs, though not all vendors support it.
Most modern databases have JDBC-drivers, which is what is needed for Java programs to connect to the database. You generally want type 4 drivers which do not depend on native code.
For starting I would recommend Apache Derby, which is written in Java and can be part of your program, which keeps it simple. http://db.apache.org/derby/. If you later find you need another database you replace the JDBC-driver, and double-check your SQL-statements.

Reading a CSV file into Java as a DB table

I've found numerous posts about reading CSV with Java and the APIs they were pointing at all had a line-oriented approach when it came to reading a CSV file. Something like "while you get a line, get the values of every column".
I'd appreciate a higher-level API, like in Perl where DBI allows you to use SQL on CSV like if it where a DB table. Otherwise I'll have to implement lots of access logic by myself.
Is there such an API? Am I missing something? There are some references about JDBC drivers but most are projects that haven't been updated the last 5 years.
You can use HSQL in order to do it, see the following links from the docs and a blog post describing exactly that.
You could give H2Database a go - it is rather heavy weight, but at least it is maintained.
Are you trying to avoid using a regular database for accessing CSV? MySQL supports CSV as one of it's table types if you are open to using a database system.
yes, JDBC with a CSV driver. You can try implement yourself or just try something like HXTT

Categories