Hello,
please make sure to always cc the mailing list, as we can't provide personalized support for free, but we try to supports as much as possible on our mailing list, but others should benefit from it as well.
However, I have to say that I have the feeling you lack a basic understand of Java and you might be better of learning Java fundamentals first. Also, given that you said you are still in school you might want to ask your lecturer or a TA to give you hands-on help. Having said that, you simply have to do a new Check("mydatabase").execute(context); with context holding a Context object.
Please take a look at the source code example I linked to in the last mail, it really follows the exact same principle.
Cheers Dirk
On 07/24/2015 09:29 AM, Yassine Hamdouni wrote:
hi Dirk ,
can you give me a sample of Check() in basex because I ue it for checking the existence the databaseX but i don't now how use it .
new Check ("C:\Program Files (x86)\BaseX\data\nomDeLaBaseDeDonnee");
Regards
2015-07-23 16:12 GMT+02:00 Dirk Kirsten <dk@basex.org mailto:dk@basex.org>:
Hello, please be much more specific what you want to do and what does not work. That your tutor does not agree is not a proper problem description - Why does he not agree, what does not work as expected? However, I seriously doubt you ever attempted to run this code sample, so this should be the first thing to do. If you do, you should notice at least compiler warnings as for example your statement "final Context context = null;" is not really useful as it initializes the variables context with null and can not be changed. So your next usage of this variable will fail. Also, you always have to execute database commands against a database context. Please take a look at our examples, e.g. at https://github.com/BaseXdb/basex/blob/master/basex-examples/src/main/java/org/basex/examples/local/CreateCollection.java Cheers, Dirk On 07/23/2015 01:52 PM, Yassine Hamdouni wrote: > hello , > > I'm studying engineering school, I have to make a java method that > allows to import the xml file, and put in a database so it ca not > exist creates it, and after you optimize, > I do this code, but my placement tutor does not agree, is that you can > help me please. > > public void importerImpl(File dossierContenantLesXmls, String > nomDeLaBaseDeDonnee, boolean ecraserDb) { > > final Context context = null; > Parser parser = null; > File[] listefichierXml = dossierContenantLesXmls.listFiles(); > > /*tester si la base de donnée exste on l'ouvre sinon on la > crée > pour le test d'existence il y a ausi cette fonction à > voir avec Bruno > con.getDatabaseConnection(nomDeLaBaseDeDonnee); > */ > > System.out.println("------------------ opens an existing > database or creates a new one------------------ "); > if(context.soptions.dbexists("nomDeLaBaseDeDonnee")) { > new Open > ("nomDeLaBaseDeDonnee"); > }else { > try { > Data data = CreateDB.create( nomDeLaBaseDeDonnee, > parser, context, null); > new Open ("nomDeLaBaseDeDonnee"); > } catch (IOException ex) > { > ex.getCause(); > } > } > // parcourir une liste de fichier Xml puis ajouter chaque > fichier a basex > for (int i=0;i<=listefichierXml.length;i++){ > new Add("listefichierXml[i].getAbsolutePath()"); > } > new Optimize(); > context.close(); > } > } > > > > > > -- > cordialement > > HAMDOUNI Yassine > -- Dirk Kirsten, BaseX GmbH, http://basexgmbh.de |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
-- cordialement
HAMDOUNI Yassine
basex-talk@mailman.uni-konstanz.de