]> source.dussan.org Git - jackcess.git/commitdiff
add TableBuilder utility
authorJames Ahlborn <jtahlborn@yahoo.com>
Thu, 20 Mar 2008 16:32:22 +0000 (16:32 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Thu, 20 Mar 2008 16:32:22 +0000 (16:32 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@288 f203690c-595d-4dc9-a70b-905162fa7fd2

src/site/xdoc/index.xml

index 9425c4650bd493dcc699092801bb33426e50a9f6..dbd5bcb2ea234a1903f33c6db459295c9de412b1 100644 (file)
     <section name="Sample code">
         <ul>
           <li>Displaying the contents of a table:
-            <source>System.out.println(Database.open(new File("my.mdb")).getTable("MyTable").display());</source>
+            <source>System.out.println(Database.open(new File("my.mdb")).getTable("MyTable").display());
+</source>
           </li>
           <li>Creating a new table and writing data into it:
             <source>Database db = Database.create(new File("new.mdb"));
-Column a = new Column();
-a.setName("a");
-a.setSQLType(Types.INTEGER);
-Column b = new Column();
-b.setName("b");
-b.setSQLType(Types.VARCHAR);
-db.createTable("NewTable", Arrays.asList(a, b));
-Table newTable = db.getTable("NewTable");
-newTable.addRow(new Object[] {1, "foo"});</source>
+Table newTable = new TableBuilder("NewTable")
+  .addColumn(new ColumnBuilder("a")
+             .setSQLType(Types.INTEGER)
+             .toColumn())
+  .addColumn(new ColumnBuilder("b")
+             .setSQLType(Types.VARCHAR)
+             .toColumn())
+  .toTable(db);
+newTable.addRow(1, "foo");
+</source>
           </li>
           <li>Copying the contents of a JDBC ResultSet (e.g. from an
 external database) into a new table: