access basex through xmldb-api -- no connection -- Invalid URI error
Tuesday, 14 January 2014 · 4 messages
IK
Ioannis Kavvouras14 Jan 2014 13:16 #
Hello,
I am trying to connect to a baseX (remote) server through xmldb-api following the examples in the git-hub but it fails giving Invalid Uri error.
I can access the database through REST using the following url: http://<serverip>:8181/BaseX772/rest/wcs-collection/
but I cannot connect using the xmldb url
xmldb:basex://<serverip>:1984/wcs-collection
or xmldb:basex://<serverip>:1984/
or xmldb:basex://<serverip>:1984/rest
or using the 8181 port.
Regards
Yannis
MSc Student at the University of Athens, Greece
CG
Christian Grün14 Jan 2014 13:23 #
Hi Ioannis,
Quoted text · Ioannis Kavvouras · 2 lines
> I am trying to connect to a baseX (remote) server through xmldb-api > following the examples in the git-hub but it fails giving Invalid Uri error.
Could you please provide us with a little code snippet? Do the examples work that are linked from our examples page [1]?
Best,
Christian
PS: We tend to deprecate the use of the XML:DB API, because both the spec and our driver has not been updated for a while. The XQJ API is probably the more up-to-date choice.
[1] http://docs.basex.org/wiki/Java_Examples
Quoted text · Ioannis Kavvouras · 16 lines
> I can access the database through REST using the following url: > http://<serverip>:8181/BaseX772/rest/wcs-collection/ > but I cannot connect using the xmldb url > xmldb:basex://<serverip>:1984/wcs-collection > or xmldb:basex://<serverip>:1984/ > or xmldb:basex://<serverip>:1984/rest > or using the 8181 port. > > Regards > Yannis > > MSc Student at the University of Athens, Greece > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
IK
Ioannis Kavvouras14 Jan 2014 13:55 #
Thank you for the reply Christian,
I 've not tried the examples in the [1], but the ones I am using are identical.
code snippet:
Class cl = Class.forName("org.basex.api.xmldb.BXDatabase");
Database database = (Database) cl.newInstance();
DatabaseManager.registerDatabase(database);
DatabaseManager.getCollection("xmldb:basex://<theserverip>:1984/wcs-collection", "admin", "admin") //error in this line
I 've just tried the XQJ
try {
XQDataSource xqjd = new BaseXXQDataSource();
xqjd.setProperty("serverName",
"http://<theserverip>:1984/wcs-collection/");
xqjd.setProperty("port", "1984");
XQConnection xqjc = xqjd.getConnection("admin", "admin");
} catch (XQException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
and I have an java.net.UnknownHostException.Regards
Yannis
Quoted text · Christian Grün · 34 lines
On 01/14/2014 02:23 PM, Christian Grün wrote: > Hi Ioannis, > >> I am trying to connect to a baseX (remote) server through xmldb-api >> following the examples in the git-hub but it fails giving Invalid Uri error. > Could you please provide us with a little code snippet? Do the > examples work that are linked from our examples page [1]? > > Best, > Christian > > PS: We tend to deprecate the use of the XML:DB API, because both the > spec and our driver has not been updated for a while. The XQJ API is > probably the more up-to-date choice. > > [1] http://docs.basex.org/wiki/Java_Examples > > >> I can access the database through REST using the following url: >> http://<serverip>:8181/BaseX772/rest/wcs-collection/ >> but I cannot connect using the xmldb url >> xmldb:basex://<serverip>:1984/wcs-collection >> or xmldb:basex://<serverip>:1984/ >> or xmldb:basex://<serverip>:1984/rest >> or using the 8181 port. >> >> Regards >> Yannis >> >> MSc Student at the University of Athens, Greece >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
CG
Christian Grün14 Jan 2014 16:38 #
Quoted text · Ioannis Kavvouras · 1 line
> DatabaseManager.getCollection("xmldb:basex://<theserverip>:1984/wcs-collection",
So the reason is probably your server ip. Please note that the BaseX XML:DB API only works in embedded mode (using localhost).
Quoted text · Ioannis Kavvouras · 4 lines
> I 've just tried the XQJ > xqjd.setProperty("serverName", > "http://<theserverip>:1984/wcs-collection/"); > and I have an java.net.UnknownHostException.
XQJ should indeed communicate with the database server. Are you are that your server is running?
Best,
Christian
Written for BaseX 7.7. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery