XML processors for executing xqj in java - java

I need to query xml data using XQJ in my java application. I wanted to know the options that I have for xml/xquery processors.
I explored and got to know about:
oracle's xquery processor that is shipped with Oracle 11g
Saxon.
Any other suggestions?

You might want to try BaseX, which also offers a full implementation of XQJ:
http://basex.org/products/
http://docs.basex.org/index.php?title=Special%3ASearch&search=xqj
You will most probably get better results when using the native APIs, no matter which processor you are using (but of course there are reasons for using XQJ as well).
Hope this helps,
Hannes

You could certainly try MarkLogic, eXist, BaseX or Sedna XQJ drivers which are located at http://xqj.net
It would be daft to use vendor propriety APIs as you will be locked into a particular database vendor, with no improvement in performance.
Also you could try checking out the XQJ entry on Wikipedia for more clarity:
http://en.wikipedia.org/wiki/XQuery_API_for_Java

As well as having a processor you need an API. Charles Foster's XQJ.net might well help for
eXist, baseX, Sedna and Marklogic.
http://xqj.net/

zorba has an XQJ branch. Please, consult the zorba users mailing list for further information on this.

Related

Alternatives to DDLUtils from apache

I would like to know which alternatives exist to replace DDL utils from Apache.
I ask this because ddlutils project seams to be Dead, and also it does not support H2 Databases. I've searched for it, and I found suggestions like liquidbase or flyway.
My problem is: These frameworks run when project starts and change DB structure based on some XML files. They are really designed for Database Migration.
What I want is a framework to CREATE/ALTER Tables in Runtime, in a high abstraction level., i.e. supportting at least Mysql, Sqlserver, oracle, and H2.
For example I could tell to the engine that I want to create a table with a Field AGE with Type Number, and the framework would rephrase to:
create table MY( id bigint(20))
create table MY(id bigint)
create table MY (id, number)
depending on the underlying db engine.
Any suggestions?
I could see there is a patch for ddlutils, for it to support H2. However I wasn't able to patch my svn checkout...
Any help will be appreciated.
thanks in advance
rui
I know this is an old thread, but wanted to give a definitive answer.
Yes, DdlUtils is dead, hasn't seen an update in 2 years now.
However, it looks like the guys might have switched over to https://www.symmetricds.org. Their repo is https://github.com/JumpMind/symmetric-ds.
As soon as you scratch away at the surface, you'll find that the core of DdlUtils is still in there (even has some of the old Apache copyright notices).
Class names have changed, APIs have changed so there is not a 1-to-1 mapping, but it is getting regular updates and includes H2 and other database support. Honestly I'd rather be getting those things instead of keeping the old APIs.
You're not going to find a guide on using Symmetric DS in the same way as the old DdlUtils doco, but there is enough in the code that you should be able to piece it together.
Take a look on jOOQ it is very useful in generating DDL (and DML too)
create.createTable("table")
.column("column1", INTEGER)
.column("column2", VARCHAR(10).nullable(false))
.constraints(
constraint("pk").primaryKey("column1"),
constraint("uk").unique("column2"),
constraint("fk").foreignKey("column2").references("some_other_table"),
constraint("ck").check(field(name("column2")).like("A%"))
)
.execute();
This looks promising: https://bitbucket.org/aragot/play-sql-dialects/src
At least as a start.
Mogwai ERD designer might help though they do not formally support H2 but you could put H2 into compatibility mode with one of the supported DB systems: https://sourceforge.net/p/mogwai

Java Jackcess Library Documentation?

I need to read and write some data on .mdb Access file and over the web I found the Jackcess library that that does exactly that.
Unfortunately I could't find any documentation to use that. On the library website there are a couple of examples, but no real documentation. Can anyone tell me if there's some sort of documentation somewhere?
The javadoc is intended to be fairly explanatory. The primary classes would be Database and Table. The library is also heavily unit tested, so you can dig into the unit test code to see many examples. There isn't currently a great "getting started" document. It has been discussed before, but, unfortunately no one has picked up the ball on actually writing it. That said, the help forum is actively monitored.
UPDATE:
There is now a cookbook, which is the beginnings of a more comprehensive user-level documentation.
You can use jackcess-orm that use DAO pattern and POJO with annotations.

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.

Is there a simple way to do Query By Example in iBATIS?

I had hoped this was baked into the most recent release, but if it is, I can't find the docs via a simple Google search. Failing that, I'd prefer a simple library, but I'll settle for a tutorial.
Thanks.
Ibator can help you with this. Let it autogenerate everything, and you'll find by-Example Queries in the SQL Maps, as well as corresponding Java bindings in the DAOs.
Check "Example Class Usage Notes" on http://ibatis.apache.org/docs/tools/ibator/ for more information.

Using XMLBeans on Android

I was just wondering if anyone had any success in getting XMLBeans (or any other generator) to work on android. It would be very nice if I could use it because I have a very large schema that I would rather not write all the classes by hand.
I had asked about this on the android developers mailing list, but no one responded. This tells me that either they don't care, or no one feels like telling me its not possible.
If anyone knows of anything else like XMLBeans that works for android, please let me know. It would be very helpful.
Thanks,
Robbie
If you're looking to do class generation and DOM parsing, XMLBeans is probably pretty heavy-weight for a mobile device running android. All of the code generated by XMLBeans makes synchronized calls into an underlying data store that I've seen as a hot spot several times when profiling.
I can't suggest any alternatives, but I would be wary of using this even if you could get it to work, because of the afore mentioned performance issue.
You can use Castor . Just be sure, in Android 2.1, not to use default android SAXParser. You'll get namespace errors. You do this by defining the parser to be, for example, Xerces (and the you add the required JARS), in core.properties .
In android 2.2 it may be ok.
Note that if you create an xmlcontext for the unmarsheler with xerces, it still won't work, as the mapping itself would be parsed with android's SAX. It must be done at core (top level properties file) so that even the mapping is parsed by xerces.
finally - performance is as slow as you can expect... :(
Good luck
SM
I got JAXB working on Android.

Categories