Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>No way to create [an Access database] from [Java] code !</p> </blockquote> <p>Nonsense. The following works on any platform with Java and <a href="http://jackcess.sourceforge.net/" rel="nofollow">Jackcess</a>...</p> <pre class="lang-java prettyprint-override"><code>import com.healthmarketscience.jackcess.*; import java.io.File; public class bar { public static void main(String[] args) { try { DatabaseBuilder.create(Database.FileFormat.V2010, new File("/home/gord/jTest.accdb")); } catch (Exception e) { e.printStackTrace(); } System.out.println("Done!"); } } </code></pre> <p>..and the following code works in Java on Windows without Jackcess (but requires the Access Database Engine)...</p> <pre class="lang-java prettyprint-override"><code>import java.io.*; import java.nio.file.Files; import java.nio.file.Paths; public class CreateAccdb { public static void main(String[] args) { String databaseName = "C:\\__tmp\\employeedb1.accdb"; String tempScriptName = System.getenv("TEMP") + "\\$$CreateAccdbScript.vbs"; try { BufferedWriter out = new BufferedWriter(new FileWriter(tempScriptName)); out.write("Set cat = CreateObject(\"ADOX.Catalog\")"); out.newLine(); out.write("cat.Create \"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + databaseName + ";\""); out.close(); } catch (IOException e) { e.printStackTrace(); } String cmd = "cscript " + tempScriptName; try { Process p = Runtime.getRuntime().exec(cmd); p.waitFor(); BufferedReader rdr = new BufferedReader(new InputStreamReader(p.getErrorStream())); int errorLines = 0; String line = rdr.readLine(); while (line != null) { errorLines++; System.out.println(line); // display error line(s), if any line = rdr.readLine(); } if (errorLines == 0) { System.out.println("The operation completed successfully."); } } catch(Exception e) { e.printStackTrace(); } try { Files.deleteIfExists(Paths.get(tempScriptName)); } catch(Exception e) { e.printStackTrace(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload