<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>hsql &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/hsql/</link>
	<description>Feed of posts on WordPress.com tagged "hsql"</description>
	<pubDate>Wed, 02 Dec 2009 00:23:19 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[DBUnit in Eclipse]]></title>
<link>http://cvalcarcel.wordpress.com/2009/09/05/dbunit-in-eclipse/</link>
<pubDate>Sat, 05 Sep 2009 19:29:24 +0000</pubDate>
<dc:creator>cvalcarcel</dc:creator>
<guid>http://cvalcarcel.wordpress.com/2009/09/05/dbunit-in-eclipse/</guid>
<description><![CDATA[Just the other day I was wondering how DBUnit was doing. As a former consultant I used to use DBUnit]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Just the other day I was wondering how <a href="http://dbunit.sourceforge.net/">DBUnit</a> was doing. As a former consultant I used to use DBUnit along with various <a href="http://www.junit.org/">JUnit</a> extensions on a regular basis.</p>
<p>Given that <a href="http://eclipse.org/">Eclipse</a> has moved on, JUnit has moved on and DBUnit has moved on I thought I would present a straightforward example of how to use DBUnit with JUnit 4.0 and Eclipse.</p>
<p>Not that much has changed therefore there is not going to be a lot of hand holding here.</p>
<h2>Assumptions</h2>
<p><a href="http://eclipse.org/downloads/">Eclipse 3.5</a><br />
JUnit 4.0 &#8211; included with Eclipse<br />
<a href="http://sourceforge.net/projects/dbunit/files/dbunit/2.4.5/dbunit-2.4.5.jar/download">DBUnit 2.4.5</a><br />
<a href="http://www.slf4j.org/dist/slf4j-1.5.8.zip">SLF4J 1.5.8</a> &#8211; DBUnit needs this<br />
<a href="http://sourceforge.net/projects/hsqldb/files/hsqldb/hsqldb_1_8_0/hsqldb_1_8_0_10.zip/download">HSQL DB 1.8.0</a></p>
<p>I implemented this example on <a href="http://www.kubuntu.org/">Kubuntu</a> 9.10, if that makes any difference.</p>
<p>If you are new to Eclipse then just download any version that seems reasonable as long as it includes a Java development environment.</p>
<h2>The Easy Part</h2>
<p>Make sure all of the above software is available somewhere on your machine. If not, install all the software in your favorite places.</p>
<p>Start Eclipse.</p>
<h2>The Short Version</h2>
<ol>
<li>Start your database</li>
<li>Create a Java Project</li>
<li>Add DBUnit to your classpath</li>
<li>Write and run a database test
<ul>
<li>Create initial and expected dataset files</li>
<li>Extend DBTestCase (inheritance) or use a JUnit class (composition)</li>
<li>Implement your test methods</li>
</ul>
</li>
</ol>
<h2>The Longer Version</h2>
<h3>Start your database</h3>
<p>I don&#8217;t have a database to run so I downloaded and installed HSQL. To run the HSQL server, which I prefer in examples, open a command window, go to the HSQL folder and run:</p>
<p>java -cp lib/hsqldb.jar org.hsqldb.Server -database.0 file:hiddenclause -dbname.0 xdb</p>
<p>In this case the database name is <code>xdb</code> with the database files named <code>hiddenclause.*</code>. Call your files whatever. I will add test data later.</p>
<p>My Eclipse default configuration includes:<br />
Source folder name: <code>src</code><br />
Output folder name: <code>classes</code></p>
<p>Default execution environment: JavaSE-1.6</p>
<h3>Create a Java Project</h3>
<p>Create a Java Project named <code>DBUnitExample</code>. &#8216;Nuff said.</p>
<h3>Add DBUnit to your classpath</h3>
<p>Once the project appears in the <strong>Package Explorer</strong>, right click on the project name and select Properties &#8211;&#62; Java Build Path &#8211;&#62; Libraries. Click <strong>Add External JARs</strong> and add the DBUnit JAR file, in this case <strong>dbunit-2.4.5.jar</strong>, to the list of libraries in the classpath. Yes, you could also have done this when you first created the project.</p>
<p>Add:<br />
- <code>slf4j-api-1.5.8.jar</code><br />
- <code>slf4j-simple-1.5.8.jar</code><br />
- <code>hsqldb.jar</code><br />
to the classpath as well.</p>
<p>Click OK to close the Properties window.</p>
<h3>Write and run a database test</h3>
<h4>Add Test Data</h4>
<p>As running a test on a fresh database is a little difficult start the HSQL Database Manager from another shell (in the HSQL directory):</p>
<p><code>java -cp lib/hsqldb.jar org.hsqldb.util.DatabaseManager</code></p>
<p>In the Connect window enter:<br />
Setting Name: <strong>hiddenclause example</strong><br />
Type: <strong>HSQL Database Engine Server</strong><br />
Driver: <strong>org.hsqldb.jdbcDriver</strong><br />
URL: <strong>jdbc:hsqldb:hsql://localhost/xdb</strong><br />
User: <strong>sa</strong><br />
Password: [leave blank]</p>
<p>Click <strong>OK</strong>.</p>
<p>Almost done. Select <strong>Options &#8211;&#62; Insert Test Data.</strong> Now we have 4 tables worth of data to test with. Run a delete on the CUSTOMER table so that is is empty.</p>
<p>Close the Database Manager.</p>
<h4>Write a Database Test</h4>
<p>The steps for writing a DBUnit test are:<br />
1. Create initial and expected dataset files<br />
2. Extend <code>DBTestCase</code> (inheritance) or use a JUnit class (composition)<br />
3. Implement your test methods</p>
<p>Once you get comfortable with that the additional steps are:<br />
1. Create initial and expected dataset files<br />
2. Extend <code>DBTestCase</code> (inheritance) or use a JUnit class (composition)<br />
3. Implement <code>getSetUpOperation()</code> and <code>getTearDownOperation()</code> (optional)<br />
4. Override <code>setUpDatabaseConfig()</code> (optional)<br />
5. Implement your test methods</p>
<p>We&#8217;ll just do the first one using the test data created by HSQL.</p>
<h5>Create initial and expected dataset files</h5>
<p>The DBUnit dataset can come from anywhere (files, databases, spreadsheets, etc.). Where the data comes from is hidden behind the class that implements IDataSet. For this example, we will use XML datasets.</p>
<p>Here is the initial dataset file:<br />
customer-init.xml</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;dataset.
    &lt;CUSTOMER /&gt;
&lt;/dataset&gt;
</pre>
<p>Here is the expected dataset (what we expect to find in the database after executing some code):</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;dataset&gt;
     &lt;CUSTOMER ID=&quot;1&quot;
               FIRSTNAME=&quot;John&quot;
               LASTNAME=&quot;Smith&quot;
               STREET=&quot;1 Main Street&quot;
               CITY=&quot;Anycity&quot; /&gt;
&lt;/dataset&gt;
</pre>
<h5>Extend DBTestCase (inheritance) or use a JUnit class (composition)</h5>
<p>The first version of CustomerTest will inherit from the DBUnit class DBTestCase. That is the recommended way of creating a DBUnit test. It uses the JUnit 3.8.2 classes which still works even with the JUnit 4.0 JAR file.</p>
<pre class="brush: java;">
public class CustomerTest extends DBTestCase {
...
    @Override
    protected IDataSet getDataSet() throws Exception {
        ...
    }
}
</pre>
<p>The getDataSet() method is called to initialize the database before the test. Consider it part of your setup logic. Let&#8217;s load the initialization dataset.</p>
<pre class="brush: java;">
    @Override
    protected IDataSet getDataSet() throws Exception {
        return new FlatXmlDataSet(
                 new FileInputStream(&quot;customer-init.xml&quot;));
    }</pre>
<p>There are a number of properties that need to be set prior to DBUnit doing its magic. You can set those properties in the constructor:</p>
<pre class="brush: java;">
    public CustomerTest(String name) {
        super(name);
        System.setProperty(
          PropertiesBasedJdbcDatabaseTester.DBUNIT_DRIVER_CLASS,
          &quot;org.hsqldb.jdbcDriver&quot;);
        System.setProperty(
          PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL,
          &quot;jdbc:hsqldb:hsql://localhost/xdb&quot;);
        System.setProperty(
          PropertiesBasedJdbcDatabaseTester.DBUNIT_USERNAME,
          &quot;sa&quot;);
        System.setProperty(
          PropertiesBasedJdbcDatabaseTester.DBUNIT_PASSWORD,
          &quot;&quot;);

        _customerFactory = CustomerFactory.getInstance();
    }
</pre>
<p>In real life you would set the driver name, connection URL and username and password to their appropriate values.</p>
<h5>Implement your test methods</h5>
<p>For this example, we are going to test an insert into the db.</p>
<pre class="brush: java;">
    public void testInsert() throws Exception {
        // insert a customer into the database
        Customer customer = _customerFactory.create(&quot;John&quot;, &quot;Smith&quot;);
        customer.setStreet(&quot;1 Main Street&quot;);
        customer.setCity(&quot;Anycity&quot;);
        _customerFactory.update(customer);
...
</pre>
<p>The code for the <code>CustomerFactory</code> and <code>Customer</code> are at the end of this post.</p>
<p>The data that has just been entered into the database becomes your actual assertable values. Go get them.</p>
<pre class="brush: java;">
        // get the actual table values
        IDatabaseConnection connection = getConnection();
        IDataSet databaseDataSet = connection.createDataSet();
        ITable actualTable = databaseDataSet.getTable(&quot;CUSTOMER&quot;);
</pre>
<p>The values defined in customer-expected.xml are what you expect the values to be. Go get them.</p>
<pre class="brush: java;">
        // get the expected table values
        IDataSet expectedDataSet = new FlatXmlDataSet(
                                          new FileInputStream(&quot;customer-expected.xml&quot;));
        ITable expectedTable = expectedDataSet.getTable(&quot;CUSTOMER&quot;);
</pre>
<p>Check the actual against the expected and complain or not as the case may be.</pre>
<p>Assertion.assertEquals(expectedTable, actualTable);<br />
}[/sourcecode]<br />
A version that uses a JUnit class as a wrapper around the DBUnit code looks like this:</p>
<pre class="brush: java;">
/**
 * This is an example only! Use it for anything else at your own risk!
 * You have been warned! Coder/user beware!
 *
 * copyright 2009 Carlos Valcarcel
 */
package hiddenclause.example.dbunit;

import java.io.FileInputStream;

import org.dbunit.Assertion;
import org.dbunit.IDatabaseTester;
import org.dbunit.JdbcDatabaseTester;
import org.dbunit.database.IDatabaseConnection;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.ITable;
import org.dbunit.dataset.xml.FlatXmlDataSet;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * @author carlos
 */
public class CustomerJunitTest {

    private CustomerFactory _customerFactory;

    private IDatabaseTester databaseTester;

    @Before
    public void setUp() throws Exception {
        databaseTester = new JdbcDatabaseTester(&quot;org.hsqldb.jdbcDriver&quot;,
                                                &quot;jdbc:hsqldb:hsql://localhost/xdb&quot;,
                                                &quot;sa&quot;, &quot;&quot;);
        // initialize your dataset here
        IDataSet dataSet = new FlatXmlDataSet(new FileInputStream(&quot;customer-init.xml&quot;));

        databaseTester.setDataSet(dataSet);

        // will call default setUpOperation
        databaseTester.onSetup();

        _customerFactory = CustomerFactory.getInstance();
    }

    @Test
    public void testInsert() throws Exception {
        // insert a customer into the database
        Customer customer = _customerFactory.create(&quot;John&quot;, &quot;Smith&quot;);
        customer.setStreet(&quot;1 Main Street&quot;);
        customer.setCity(&quot;Anycity&quot;);
        _customerFactory.update(customer);

        // get the actual table values
        IDatabaseConnection connection = databaseTester.getConnection();
        IDataSet databaseDataSet = connection.createDataSet();
        ITable actualTable = databaseDataSet.getTable(&quot;CUSTOMER&quot;);

        // get the expected table values
        IDataSet expectedDataSet = new FlatXmlDataSet(
                                          new FileInputStream(&quot;customer-expected.xml&quot;));
        ITable expectedTable = expectedDataSet.getTable(&quot;CUSTOMER&quot;);

        Assertion.assertEquals(expectedTable, actualTable);

    }

    @After
    public void tearDown() throws Exception {
        databaseTester.onTearDown();
    }
}</pre>
<p>Things to notice:<br />
- less configuration (the <code>System.setProperty()</code> calls are gone)<br />
- explicit creation of a <code>IDatabaseTester</code> object<br />
- explicit call to <code>databaseTester.onSetup()</code><br />
- explicit call to <code>databaseTester.onTearDown()<br />
</code></p>
<h4>Run the Database Test</h4>
<p>With all the pieces in place it is now safe to run the <code>CustomerTest</code> DBUnit class. You will probably see some warning messages in the <strong>Console</strong> view about the data type factory being incorrect. You can safely ignore that error for this example. In real life you probably want to instantiate a new <code>DataTypeFactory</code> based on the database you are using.</p>
<p>If any of the above does not quite work as described let me know and I will update the above explanation.</p>
<h2>The Code</h2>
<p>customer-init.xml</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;dataset&gt;
    &lt;CUSTOMER /&gt;
&lt;/dataset&gt;
</pre>
<p>customer-expected.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;dataset&gt;
    &lt;CUSTOMER ID=&quot;1&quot;
              FIRSTNAME=&quot;John&quot;
              LASTNAME=&quot;Smith&quot;
              STREET=&quot;1 Main Street&quot;
              CITY=&quot;Anycity&quot; /&gt;
&lt;/dataset&gt;
</pre>
<p>CustomerTest.java</p>
<pre class="brush: java;">
/**
 * This is an example only! Use it for anything else at your own risk!
 * You have been warned! Coder/user beware!
 *
 * copyright 2009 Carlos Valcarcel
 */
package hiddenclause.example.dbunit;

import java.io.FileInputStream;

import org.dbunit.Assertion;
import org.dbunit.DBTestCase;
import org.dbunit.PropertiesBasedJdbcDatabaseTester;
import org.dbunit.database.IDatabaseConnection;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.ITable;
import org.dbunit.dataset.xml.FlatXmlDataSet;

/**
 * @author carlos
 */
public class CustomerTest extends DBTestCase {

    private CustomerFactory _customerFactory;

    public CustomerTest(String name) {
        super(name);
        System.setProperty(
          PropertiesBasedJdbcDatabaseTester.DBUNIT_DRIVER_CLASS,
          &quot;org.hsqldb.jdbcDriver&quot;);
        System.setProperty(
          PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL,
          &quot;jdbc:hsqldb:hsql://localhost/xdb&quot;);
        System.setProperty(
          PropertiesBasedJdbcDatabaseTester.DBUNIT_USERNAME,
          &quot;sa&quot;);
        System.setProperty(
          PropertiesBasedJdbcDatabaseTester.DBUNIT_PASSWORD,
          &quot;&quot;);

        _customerFactory = CustomerFactory.getInstance();
    }

    public void testInsert() throws Exception {
        // insert a customer into the database
        Customer customer = _customerFactory.create(&quot;John&quot;, &quot;Smith&quot;);
        customer.setStreet(&quot;1 Main Street&quot;);
        customer.setCity(&quot;Anycity&quot;);
        _customerFactory.update(customer);

        // get the actual table values
        IDatabaseConnection connection = getConnection();
        IDataSet databaseDataSet = connection.createDataSet();
        ITable actualTable = databaseDataSet.getTable(&quot;CUSTOMER&quot;);

        // get the expected table values
        IDataSet expectedDataSet = new FlatXmlDataSet(
                                          new FileInputStream(&quot;customer-expected.xml&quot;));
        ITable expectedTable = expectedDataSet.getTable(&quot;CUSTOMER&quot;);

        Assertion.assertEquals(expectedTable, actualTable);

    }
    /*
     * (non-Javadoc)
     * @see org.dbunit.DatabaseTestCase#getDataSet()
     */
    @Override
    protected IDataSet getDataSet() throws Exception {
        return new FlatXmlDataSet(
                 new FileInputStream(&quot;customer-init.xml&quot;));
    }

}
</pre>
<p>CustomerFactory.java</p>
<pre class="brush: java;">
/**
 * This is an example only! Use it for anything else at your own risk!
 * You have been warned! Coder/user beware!
 *
 * copyright 2009 Carlos Valcarcel
 */
package hiddenclause.example.dbunit;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @author carlos
 *
 */
public class CustomerFactory {

    static {
        try {
            Class.forName(&quot;org.hsqldb.jdbcDriver&quot;);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    public static CustomerFactory getInstance()
    {
        return new CustomerFactory();
    }

    public Customer create(String firstName, String lastName) {
        return new Customer(1, firstName, lastName);
    }

    public void update(Customer customer) throws SQLException {
        Connection connection = DriverManager.getConnection(&quot;jdbc:hsqldb:hsql://localhost/xdb&quot;);
        String sql = &quot;insert into customer (id, firstname, lastname, street, city) values (&quot;
                   + customer.getId() + &quot;, &quot;
                   + &quot;'&quot; + customer.getFirstName() + &quot;', &quot;
                   + &quot;'&quot; + customer.getLastName() + &quot;', &quot;
                   + &quot;'&quot; + customer.getStreet() + &quot;', &quot;
                   + &quot;'&quot; + customer.getCity() + &quot;'&quot;
                   + &quot;)&quot;;

        Statement stmt = connection.createStatement();
        stmt.execute(sql);
        if (stmt.getUpdateCount() != 1) {
            throw new SQLException(&quot;Insert failed!&quot;);
        }
    }

}
</pre>
<p>Customer.java</p>
<pre class="brush: java;">
/**
 * This is an example only! Use it for anything else at your own risk!
 * You have been warned! Coder/user beware!
 *
 * copyright 2009 Carlos Valcarcel
 */
package hiddenclause.example.dbunit;

/**
 * @author carlos
 *
 */
public class Customer {

    private int _id;
    private String _firstName;
    private String _lastName;
    private String _street;
    private String _city;

    public Customer(int id, String firstName, String lastName) {
        _id = id;
        _firstName = firstName;
        _lastName = lastName;
    }

    public int getId() {
        return _id;
    }

    public String getFirstName() {
        return _firstName;
    }

    public String getLastName() {
        return _lastName;
    }

    public String getStreet() {
        return _street;
    }

    public String getCity() {
        return _city;
    }

    public void setStreet(String street) {
        _street = street;
    }

    public void setCity(String city) {
        _city = city;
    }

}
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[SQL Formatter and Pretty Printer]]></title>
<link>http://markfarnsworth.wordpress.com/2009/07/13/sql/</link>
<pubDate>Mon, 13 Jul 2009 01:01:39 +0000</pubDate>
<dc:creator>Mark</dc:creator>
<guid>http://markfarnsworth.wordpress.com/2009/07/13/sql/</guid>
<description><![CDATA[A couple of weeks ago I started work to build a universal parser for SQL.  The work started with a b]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>A couple of weeks ago I started work to build a universal parser for SQL.  The work started with a basic need I had for minimal parsing of SQL statements in the GarinDriver JDBC project.  I was unable to find any open source parser code that would fully support the basic structure used by MySQL, PostgreSQL, Oracle, and other similar systems.   In particular, I wanted support for q&#8217;&#60;&#62;&#8217; used by Oracle in addition to the SQL standard string encoding, MySQL&#8217;s use of C style string escaping, and $tag$ style strings for PostgreSQL and H2.  Conceptually I wanted to build ONE parser that could be configured to properly parse ANY dialect and that would support a framework for adding additional exceptions in the future.</p>
<p>The basics of my parser framework is now complete. It is smart enough to parse MySQL, H2, HSQLDB, Oracle, PostgreSQL, and ISO SQL2003 variants. The shallow parsing framework uses a base Token class and a range of subclasses to describe the most basic elements of the SQL grammar. The parser identifies the core keywords, statement boundaries, string, comment, and identifier limits but does not look into deeper language issues like statement structure.   One benifit of the shallow parsing is that it allows for flexibiltiy and does not require a complete BNF style grammar.  Even with only this basic level, it is possible to leverage this code for useful stuff beyond the GarinDriver, LiquiBase data migration solution.</p>
<p>The following bare bones test page demonstrates how the parser can be used to format and add color to SQL batches.  The code would also be useful for someone building a universal SQL editor.<br />
<a style="text-decoration:none;" href="http://markfarnsworth-dev.appspot.com/RenderSql">http://markfarnsworth-dev.appspot.com/RenderSql</a></p>
<p>Overall, I am happy with the approach and while I plan to use a more established framework like ANTLR or XTEXT for future deep parsing efforts I feel my homegrown framework provides a better approach for shallow parsing vs. the larger and more complex language tools that I have reviewed.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[A Universal Parser for SQL]]></title>
<link>http://markfarnsworth.wordpress.com/2009/07/08/parse/</link>
<pubDate>Wed, 08 Jul 2009 03:11:24 +0000</pubDate>
<dc:creator>Mark</dc:creator>
<guid>http://markfarnsworth.wordpress.com/2009/07/08/parse/</guid>
<description><![CDATA[I recently completed some work on the GarinDriver to research a more flexible model for database sch]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I recently completed some work on the GarinDriver to research a more flexible model for database schema change management.   This work gave me a chance to dig a little deeper into the nuts and bolts of Java database interactions.  Working to track schema changes and support a wide range of databases increased my appreciating for powerful open source database platforms available today.  In particular, working with H2 Database gave me a chance to explore what I now think is one of the hidden treasures of the open source DB marketplace.  Overall it was a fun bit of hobby coding and I believe it will be useful in future real world projects.</p>
<p>Working on the driver, one challenge that went beyond my expectation was parsing the various dialects of SQL.   In a review of current open source projects, I did not find any public license parsers that can parse statements from ALL database systems.  In a sense, we are supposed to have a standard but it is really well followed by the vendors and as such writing a universal parse is a bit difficult.   I had some free time this weekend so I took on the challenge since it is an area where the open source community really does not currently have a good solution.  For example the tools that ship with Eclipse can not parse the $tag$ style strings from PostgreSQL or the q&#8217;[O'Brian]&#8216; style supported by Oracle.   In any case,  I had some free time and interest so I decided to build my own parser.  Without such a parser it would be impossible to provide full support for the statement execution model needed to support the GarinDriver desgin.  Workarounds were possible but a proper parser felt like the best approach.</p>
<p>Building a parser is complex and often involves specialized tools (i.e. ANTLR, BISON, JAVACC, FLEX, LEX, YACC, etc).  There are benefits and drawbacks to the traditional grammar definition and parser generator approach.   My initial review it seemed that supporting the often contradictory approaches used by different systems would be quite difficult with these tools.</p>
<p>Since all that I needed for the GarinDriver/LiquiBase project was &#8220;shallow parsing&#8221; my approach was to use a small framework of Java classes.  The use of my own framework allows me to share logic across the SQL dialects and provided a chance to explore idea for a more dynamic approach to &#8220;shallow parsing&#8221;.   So far the approach seems to be working out nicely although I am considering building a deep parser at some point later on with the Eclipse <a href="http://www.eclipse.org/Xtext/">XTEXT</a> project but for now the flexiiblity of a home grown hand coded parser has proved to be a viable approach for &#8220;shallow parsing&#8221;.</p>
<p><strong>Parser Fun:</strong></p>
<ul>
<li>Standard SQL comments have EOL style (&#8211;) and the block style (/* */).</li>
<li>Block style comments nest within each other so parser must count the nesting levels.</li>
<li>MySQL supports pound sign comments in addition to the standard forms.</li>
<li>HSQLDB supports // style comments in addition to the standard forms.</li>
<li>Standard SQL uses double quotes for identifiers and single quotes for text strings.</li>
<li>The parser must support both including quote symbol doubling for escapes (i.e. O&#8221;Brian or My &#8220;&#8221;big&#8221;" table.</li>
<li>Oracle supports q&#8217;[O'Brian]&#8216; in addition to the standard style.</li>
<li>MySQL uses C style string encoding (i.e. &#8216;O\&#8217;Brian&#8217; ).</li>
<li>PostgreSQL supports $tag$O&#8217;Brian$tag$ style in addition to the standard forms AND the mysql format.</li>
</ul>
<p>My parser uses object oriented techniques to define a base token concept, extend the base concept for SqlStatements, and then extend the SqlStatements to define the dialect variants in what I hope will be an extendable framework.  This approach provides more flexibility for future growth vs. more static models and parser generator tools.  In any case the approach seems to work and the ability to use object orientation to extend the parser in new directions seems like a good thing.</p>
<p>As with other hobby projects, my work in this area is EPL and hosted on Google code.  The documentation is sparse but if you are looking for SQL parser code you may find that this code can help you develop new and interesting tools for working with SQL systems.</p>
<p><a href="http://code.google.com/p/garinparser/">http://code.google.com/p/garinparser/</a></p>
<p>If you decide to use the parser please let me know.  Also, if you can define a legal SQL statement that does not parse correctly with my parser let me know since I like to eat tasty bugs.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[TDD na przykładzie Grails - klasy domenowe i ich reguły]]></title>
<link>http://chlebik.wordpress.com/2009/04/28/tdd-na-przykladzie-grails-klasy-domenowe-i-ich-reguly/</link>
<pubDate>Tue, 28 Apr 2009 00:22:24 +0000</pubDate>
<dc:creator>chlebik</dc:creator>
<guid>http://chlebik.wordpress.com/2009/04/28/tdd-na-przykladzie-grails-klasy-domenowe-i-ich-reguly/</guid>
<description><![CDATA[Nie tak dawno temu zawędrowałem na spotkanie WJUGa, na którym poruszono temat DDD (Domain Driven Dev]]></description>
<content:encoded><![CDATA[Nie tak dawno temu zawędrowałem na spotkanie WJUGa, na którym poruszono temat DDD (Domain Driven Dev]]></content:encoded>
</item>
<item>
<title><![CDATA[Java developer for sale]]></title>
<link>http://spillerlaszlo.wordpress.com/2009/04/20/java-developer-for-sale/</link>
<pubDate>Mon, 20 Apr 2009 09:15:26 +0000</pubDate>
<dc:creator>Spiller László</dc:creator>
<guid>http://spillerlaszlo.wordpress.com/2009/04/20/java-developer-for-sale/</guid>
<description><![CDATA[Gained 6 years of experience as a Java developer. He focused on the development of healthcare and me]]></description>
<content:encoded><![CDATA[Gained 6 years of experience as a Java developer. He focused on the development of healthcare and me]]></content:encoded>
</item>
<item>
<title><![CDATA[Hibernate, Spring and Maven]]></title>
<link>http://thomassundberg.wordpress.com/2009/04/09/hibernate-spring-and-maven/</link>
<pubDate>Thu, 09 Apr 2009 11:18:33 +0000</pubDate>
<dc:creator>Thomas Sundberg</dc:creator>
<guid>http://thomassundberg.wordpress.com/2009/04/09/hibernate-spring-and-maven/</guid>
<description><![CDATA[We will create a small Java application that connects to a database using Hibernate. We will use Spr]]></description>
<content:encoded><![CDATA[We will create a small Java application that connects to a database using Hibernate. We will use Spr]]></content:encoded>
</item>
<item>
<title><![CDATA[Template for JSF/Richfaces,Spring,Hibernate]]></title>
<link>http://laurentbouin.wordpress.com/2009/02/05/template-for-jsfrichfacesspringhibernate/</link>
<pubDate>Thu, 05 Feb 2009 10:49:48 +0000</pubDate>
<dc:creator>laurentbouin</dc:creator>
<guid>http://laurentbouin.wordpress.com/2009/02/05/template-for-jsfrichfacesspringhibernate/</guid>
<description><![CDATA[Next step, based on the previous post, adding some persistance with Hibernate. For this sample i wil]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Next step, based on the <a title="See the previous post" href="http://laurentbouin.wordpress.com/2009/01/05/template-for-jsfrichfaces-projects/" target="_blank">previous post</a>, adding some persistance with Hibernate.</p>
<p>For this sample i will use <a href="http://hsqldb.org/" target="_blank">HSQLDB</a> for the &#8220;in memory&#8221; feature.</p>
<p>The sample app allow you to create &#8220;Users&#8221; containing just a username and Id.</p>
<h4>Frameworks:</h4>
<ul>
<li>Spring &#8211; 2.5.3</li>
<li>Hibernate &#8211; 3.2.1.ga</li>
<li>Hibernate-annotations &#8211; 3.3.0.ga</li>
<li>HSQLDB &#8211; 1.8.0.7</li>
<li>JSF &#8211; 1.2_04-p02</li>
<li>Richfaces &#8211; 3.2.2.SR1</li>
<li>Facelets &#8211; 1.1.14</li>
</ul>
<h3>The Value Object:</h3>
<blockquote><p><strong>package</strong> com.lb.jwitter;</p>
<p><strong>import</strong> java.io.Serializable;</p>
<p><strong>import</strong> javax.persistence.Entity;</p>
<p><strong>import</strong> javax.persistence.GeneratedValue;</p>
<p><strong>import</strong> javax.persistence.Id;</p>
<p><strong>import</strong> javax.persistence.Table;</p>
<p><strong></strong></p>
<p><strong>@Entity</strong></p>
<p><strong>@Table (name=&#8221;UTILISATEURS&#8221;)</strong></p>
<p><strong>public class</strong> User <strong>implements</strong> Serializable {</p>
<p><strong>private static final long </strong>serialVersionUID = -1989579066723007050L;</p>
<p><strong>private</strong> Long id;</p>
<p><strong>private</strong> String username;</p>
<p><strong>@Id</strong></p>
<p><strong>@GeneratedValue</strong></p>
<p><strong>public</strong> Long getId() {</p>
<p>return id;</p>
<p>}</p>
<p><strong>public void</strong> setId(Long id) {</p>
<p>this.id = id;</p>
<p>}</p>
<p><strong>public</strong> String getUsername() {</p>
<p><strong>return</strong> username;</p>
<p>}</p>
<p><strong>public void</strong> setUsername(String username) {</p>
<p>this.username = username;</p>
<p>}</p>
<p>}</p></blockquote>
<p><code>@Entity</code> : Declares the value object as an entity managed by the persistance API.</p>
<p><code>@Table</code> : Defines the table&#8217;s name in which the entities will be stored.</p>
<p><code>@Id</code> : Declares the variable behind the getter as the primary key for the entity.</p>
<p><code>@GeneratedValue</code> : The primary key will be generated automaticaly.</p>
<h4>References</h4>
<ul>
<li><a href="http://hibernate.org/397.html" target="_blank">Hibernate Entity Manager</a></li>
<li><a href="http://java.sun.com/javaee/technologies/persistence.jsp" target="_blank">Sun &#8211; Java persistence API</a></li>
<li><a href="http://www.jcp.org/en/jsr/detail?id=220" target="_blank">JSR 220: EJB 3.0 </a></li>
</ul>
<h3>Writing the <acronym title="Data Access Object">DAO</acronym> :</h3>
<blockquote><p><strong>import</strong> java.util.List;</p>
<p><strong>import</strong> org.apache.commons.logging.Log;</p>
<p><strong>import</strong> org.apache.commons.logging.LogFactory;</p>
<p><strong>import</strong> org.hibernate.SessionFactory;</p>
<p><strong>import</strong> org.hibernate.criterion.Projections;</p>
<p><strong>import</strong> org.hibernate.criterion.Restrictions;</p>
<p><strong>import</strong> org.springframework.beans.factory.annotation.Autowired;</p>
<p><strong>import</strong> org.springframework.beans.factory.annotation.Qualifier;</p>
<p><strong>import</strong> org.springframework.stereotype.Repository;</p>
<p><strong>import</strong> com.lb.jwitter.User;</p>
<p><strong>import</strong> com.lb.utils.orm.hibernate.HibernateGenericDao;</p>
<p><strong>@Repository</strong></p>
<p><strong>public class</strong> UserHibernateDao extends HibernateGenericDao&#60;User, Long&#62; <strong>implements</strong> UserDaoInterface {</p>
<p><strong>private</strong> Log log = LogFactory.getLog(UserHibernateDao.class);</p>
<p><strong>@Autowired</strong></p>
<p><strong>public</strong> UserHibernateDao(<strong>@Qualifier(&#8220;sessionFactory&#8221;)</strong> SessionFactory sessionFactory) {</p>
<p><strong>super</strong>(sessionFactory);</p>
<p>}</p>
<p><strong>public</strong> List&#60;User&#62; findAll() {</p>
<p><strong>return</strong> getSession().createCriteria(User.<strong>class</strong>).list();</p>
<p>}</p>
<p>}</p></blockquote>
<p>I wrote a class HibernateGenericDao to implements the CRUD methods, you can find it in the source code.</p>
<h3>The Service with Autowired DAO</h3>
<blockquote><p><strong>import</strong> java.io.Serializable;</p>
<p><strong>import</strong> java.util.List;</p>
<p><strong>import</strong> org.apache.commons.logging.Log;</p>
<p><strong>import</strong> org.apache.commons.logging.LogFactory;</p>
<p><strong>import</strong> org.springframework.beans.factory.annotation.Autowired;</p>
<p><strong>import</strong> org.springframework.stereotype.Service;</p>
<p><strong>import</strong> org.springframework.transaction.annotation.Transactional;</p>
<p>import com.lb.jwitter.User;</p>
<p>import com.lb.jwitter.hibernate.UserDaoInterface;</p>
<p><strong>@Service</strong>(&#8220;userService&#8221;)</p>
<p><strong>@Transactional</strong></p>
<p><strong>public class </strong>UserService <strong>implements</strong> UserServiceInterface,Serializable{</p>
<p><strong>private</strong> Log log = LogFactory.getLog(UserService.class);</p>
<p><strong>@Autowired</strong></p>
<p><strong>private</strong> UserDaoInterface userDao;</p>
<p><strong>public</strong> List&#60;User&#62; findAll(){</p>
<p>List&#60;User&#62; result = getUserDao().findAll();</p>
<p>log.info(&#8220;Number of user in DB:: &#8220;+result.size());</p>
<p><strong>return</strong> result;</p>
<p>}</p>
<p><strong>public</strong> UserDaoInterface getUserDao() {</p>
<p><strong>return</strong> userDao;</p>
<p>}</p>
<p>/**</p>
<p>* @param userDao the userDao to set</p>
<p>*/</p>
<p><strong>public</strong> <strong>void</strong> setUserDao(UserDaoInterface userDao) {</p>
<p>this.userDao = userDao;</p>
<p>}</p>
<p>}</p></blockquote>
<h3>Writing the Managed Bean</h3>
<blockquote><p>import java.io.Serializable;<br />
import java.util.List;</p>
<p>import javax.faces.application.FacesMessage;<br />
import javax.faces.component.UIComponent;<br />
import javax.faces.context.FacesContext;<br />
import javax.faces.validator.ValidatorException;</p>
<p>import org.apache.commons.logging.Log;<br />
import org.apache.commons.logging.LogFactory;<br />
import org.springframework.beans.factory.annotation.Autowired;<br />
import org.springframework.beans.factory.annotation.Qualifier;<br />
import org.springframework.context.annotation.Scope;<br />
import org.springframework.stereotype.Component;</p>
<p>import com.lb.jwitter.User;<br />
import com.lb.jwitter.service.UserServiceInterface;</p>
<p><strong>@Component<br />
@Qualifier</strong>(&#8220;userBean&#8221;)<br />
<strong>@Scope</strong>(&#8220;session&#8221;)<br />
<strong>public class</strong> UserBean implements Serializable {</p>
<p>private Log log = LogFactory.getLog(UserBean.class);</p>
<p><strong>@Autowired<br />
private</strong> UserServiceInterface userService;</p>
<p><strong>public</strong> List&#60;User&#62; getAllUsers(){<br />
<strong>return</strong> this.userService.findAll();<br />
}</p>
<p><strong>public</strong> UserServiceInterface getUserService() {<br />
<strong>return</strong> userService;<br />
}</p>
<p>/**<br />
* @param userService the userService to set<br />
*/<br />
public void setUserService(UserServiceInterface userService) {<br />
this.userService = userService;<br />
}</p>
<p>}</p></blockquote>
<p><a href="http://web.me.com/laurentbouin/Mon_Mac_et_Moi/Blog/Entr%C3%A9es/2008/10/10_I%E2%80%99m_a_MAc,_so_i_live_in_NY_City_files/jwitter.zip">Download the source code</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Starting the HSQLDB server from the command line]]></title>
<link>http://leguimaraes.wordpress.com/2008/12/25/starting-the-hsqldb-server-from-the-command-line/</link>
<pubDate>Thu, 25 Dec 2008 13:39:41 +0000</pubDate>
<dc:creator>leguimaraes</dc:creator>
<guid>http://leguimaraes.wordpress.com/2008/12/25/starting-the-hsqldb-server-from-the-command-line/</guid>
<description><![CDATA[HSQL &#8211; A Lightweight 100% Java SQL Database Engin &#8220;Peso pena&#8221; passa a ser meu novo]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>HSQL &#8211; A Lightweight 100% Java SQL Database Engin<br />
&#8220;Peso pena&#8221; passa a ser meu novo SGBD para desenvolvimento, até então usava o <a href="http://www.mysql.com/">Mysql</a></p>
<p>Para startar é simples.. faça seu download em <a href="http://hsqldb.org/">HSQL</a><br />
Descompacte, copie a biblioteca hsqldb.jar para seu classpath.</p>
<p>Na linha de comando vá até a pasta que contém o jar e execute:<br />
<code>java -classpath ./hsqldb.jar org.hsqldb.Server</code></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Slashdot: F/OSS Flat-File Database]]></title>
<link>http://blog.wolffmyren.com/2008/05/21/slashdot-foss-flat-file-database/</link>
<pubDate>Wed, 21 May 2008 20:53:02 +0000</pubDate>
<dc:creator>willwm</dc:creator>
<guid>http://blog.wolffmyren.com/2008/05/21/slashdot-foss-flat-file-database/</guid>
<description><![CDATA[Good question, actually. See the link for some answers from the /. community: Leemeng writes &#8220;]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Good question, actually. See the link for some answers from the /. community:</p>
<blockquote><p><a href="mailto:leemeng@gmail.com">Leemeng</a> writes <em>&#8220;I&#8217;m looking for a simple, free, and F/OSS flat-file database program. I&#8217;m storing info about Wi-Fi access points that I come across, maybe 8-9 fields per entry. I&#8217;ve outgrown Notepad. This info is for my own reference only; it is not going on a Web server. Googling was unhelpful, with results skewed towards SQL, Access (MS), and Oracle, all of which would be overkill for my purposes. My criteria are: it must be simple, F/OSS, must work in Windows Vista, preferably use a portable format, must not be an online app, and must not require Java. Does such a beast exist?&#8221;</em></p></blockquote>
<p>(via <a title="http://developers.slashdot.org/article.pl?sid=08/05/20/2150246" href="http://developers.slashdot.org/article.pl?sid=08/05/20/2150246">http://developers.slashdot.org/article.pl?sid=08/05/20/2150246</a>)</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[ Features Summary]]></title>
<link>http://asteriskese.wordpress.com/2008/04/27/features-summary/</link>
<pubDate>Sun, 27 Apr 2008 13:50:41 +0000</pubDate>
<dc:creator>asteriskese</dc:creator>
<guid>http://asteriskese.wordpress.com/2008/04/27/features-summary/</guid>
<description><![CDATA[JAVA 100% Java Support JDK 1.1.x, 1.2.x, 1.3.x, 1.4.x, 1.5.x, 1.6.x Extensive JDBC interface support]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>JAVA</p>
<ul>
<li>100% Java</li>
<li>Support JDK 1.1.x, 1.2.x, 1.3.x, 1.4.x, 1.5.x, 1.6.x</li>
<li>Extensive JDBC interface support with batch statement and scrollable ResultSet        functionality</li>
<li>Full JDBC DatabaseMetaData and ResultSetMetaData support</li>
<li>Java stored procedures and functions</li>
<li>Full support for PreparedStatement objects to speed up query processing</li>
</ul>
<p>SQL</p>
<ul>
<li> Relational Database Management System, with the object capabilities of        Java</li>
<li>Very extensive support for SQL:2003 Standard syntax, including most optional        features</li>
<li>Supports all base data types of the SQL Standard, including BINARY, BIT,        BOOLEAN, date-time, INTERVAL, BLOB, CLOB</li>
<li>Supports user-defined DOMAIN types, including type constraints</li>
<li>Fast SELECT, INSERT, DELETE, UPDATE and MERGE operations</li>
<li>INNER, LEFT OUTER, RIGHT OUTER and FULL joins</li>
<li>UNION, EXCEPT, INTERSECT, including use of parentheses, limits and offsets</li>
<li>Scalar (single value) SELECTS, row and correlated subqueries including        IN, EXISTS, ANY, ALL</li>
<li>Views, Temp tables and sequences</li>
<li>Primary key, unique and check constraints on single or multiple columns</li>
<li>Referential Integrity (foreign keys) on multiple columns with full cascading        options (delete, update, set null, set default)</li>
<li>ORDER BY, GROUP BY and HAVING</li>
<li>COUNT, SUM, MIN, MAX, AVG and statistical aggregate functions</li>
<li>Full support for SQL expressions such as CASE .. WHEN .. ELSE .. , NULLIF        etc.</li>
<li>SQL standard autoincrement column support plus sequences</li>
<li>Transaction COMMIT, ROLLBACK and SAVEPOINT support</li>
<li>Multiple schemata per database</li>
<li>Triggers, implemented as Java classes, or as SQL statements</li>
<li>Database security with passwords, user rights and roles with GRANT and        REVOKE</li>
<li>Extensive set of ALTER TABLE commands, including change of table column        type</li>
</ul>
<p>Persistence</p>
<ul>
<li>In-memory tables for fastest operation</li>
<li>Disk based tables for large data sets</li>
<li>Text tables with external file data sources such as CSV files</li>
<li>Disk tables (CACHED TABLE) up to 8GB and text tables up to 2GB each</li>
<li>Size of each string or binary item only limited by memory</li>
<li>Database dump as SQL script with or without data</li>
</ul>
<p>Deployment</p>
<ul>
<li>Embedded (into Java applications) and Client-Server operating modes</li>
<li>Three client server protocols: HSQL, HTTP and HSQL-BER &#8211; can run as an        HTTP web server &#8211; all with SSL option</li>
<li>Can be used in applets, read-only media (CD), inside jars, webstart and        embedded applications</li>
<li>Multiple databases per JVM</li>
</ul>
<p>Utilities</p>
<ul>
<li>Powerful and compact java command line and GUI tools for database management</li>
<li>Tranfer tool for conversion of databases to / from other popular database        managment systems</li>
</ul>
<p><!-- #EndEditable --><a href="http://hsqldb.sf.net/"> <img src="http://sourceforge.net/sflogo.php?group_id=23316" border="0" alt="SourceForge Logo" width="95" height="32" /></a> <!-- #BeginEditable "extralogo" --><!-- #EndEditable --></p>
<h6>This page last updated <!-- #BeginEditable "update" -->20    April 2008</h6>
<p>Link: http://hsqldb.org/web/hsqlFeatures.html</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[HSQL]]></title>
<link>http://asteriskese.wordpress.com/2008/04/27/hsql/</link>
<pubDate>Sun, 27 Apr 2008 13:39:36 +0000</pubDate>
<dc:creator>asteriskese</dc:creator>
<guid>http://asteriskese.wordpress.com/2008/04/27/hsql/</guid>
<description><![CDATA[HSQL là 1 hệ qtrị csdl quan hệ, đặc biệt nó được viết bằng 1 ngôn ngữ cấp cao: JAVA. Để biết thêm cá]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><div class="entrytext">
<div class="snap_preview">
<p>HSQL là 1 hệ qtrị csdl quan hệ, đặc biệt nó được viết bằng 1 ngôn ngữ cấp cao: JAVA. Để biết thêm các đặc điểm của nó , các bạn có thể xem tại đây</p>
<p>hsql features:<br />
<a href="http://hsqldb.org/web/hsqlFeatures.html" target="_blank">http://hsqldb.org/web/hsqlFeatures.html</a></p>
<p>documentation<br />
<a href="http://hsqldb.org/web/hsqlDocsFrame.html" target="_blank">http://hsqldb.org/web/hsqlDocsFrame.html</a></p>
<p>TẠI SAO NÊN DÙNG HSQL: Như mọi ng biết, mọi hệ qtcsdl đều fải cài đặt tại máy khách để có thể dùng được ứng dụng có xài hệ csdl đó. Thật là bất tiện. Có 2 phương án đẻ chúng ta chọn nếu ko làm như vậy:<br />
1/ access: gọn nhẹ, nhưng dễ bị crack password, an toàn ko cao, ko chạy trên các OS khác như linux<br />
2/ Tự viết ra chức năng lưu/backup/restore data trên các file .dat .bak -&#62; có ai siêng ngồi viết ko <img style="vertical-align:middle;" src="http://www.diendantinhoc.com/style_emoticons/default/biggrin.gif" border="0" alt="biggrin.gif" /></p>
<p>Để giải quyết vấn đề trên chúng ta cần 1 hệ csdl thân thiện (như sqlserver), cú pháp query gọn, dễ dùng như t-sql, và phải là 1 <em><strong>standalone database application</strong></em>. Lựa chọn tốt nhất theo tui hiện nay ko thể khác đó là <strong>HSQL</strong></p>
<p>VÀ BÂY GIÒ LÀ MÀN KẾ: THAO TÁC SỬ DỤNG  HSQL (VỚI TOOL VÀ SQL)</p>
<p>1/ download hsql:<br />
<a href="http://sourceforge.net/project/showfiles.php?group_id=23316" target="_blank">http://sourceforge.net/project/showfiles.php?group_id=23316</a></p>
<p>2/ Giải nén hsql.zip -&#62; folder hsqldb.zip<br />
Giải nén cũng chính là thao tác cái đặt <img style="vertical-align:middle;" src="http://www.diendantinhoc.com/style_emoticons/default/happy.gif" border="0" alt="happy.gif" />.<br />
Sau khi GIải nén xong, bạn có thể sữ dụng, ma ko cần 1 công đoạn cấu hình phức tạp nào nữa</p>
<p>3/ Sử dụng công cụ trực quan của hsql:<br />
Trong thư mục hsqldb có 1 thư mục lib, mở nó ra bạn sẽ thấy 3 file<br />
Trong bài này ta chỉ dùng hsqldb.jar<br />
Đây là file dạng executable jar file (giống exe vậy)<br />
Cách<br />
+ set path<br />
+ java -cp hsqldb.jar org.hsqldb.util.DatabaseManager</p>
<p>Ví dụ, trên máy tui cài jdk ở vị trí sau: C:\Program Files\Java\jdk1.5.0_14</p>
<p>Vậy thao tác tui cần làm là:</p>
<p>start-run-cmd<br />
cd &#60;path đến thư mục hsqldb&#62;\lib<br />
set path=.;C:\Program Files\Java\jdk1.5.0_14\bin (có thư mục bin nữa nhé)<br />
java -cp hsqldb.jar org.hsqldb.util.DatabaseManager</p>
<p>Giao diện sẽ có dạng như hình sau: <img class="linked-image" src="http://img2.freeimagehosting.net/uploads/66d3df6eab.jpg" border="0" alt="" /></p>
<p>Bạn để nguyên các configuration, ko chỉnh sửa gì nha<br />
Nhấp OK.<br />
Màn hình chính sẽ hiện ra như sau:<br />
<img class="linked-image" src="http://img2.freeimagehosting.net/uploads/d90ea049aa.jpg" border="0" alt="" /></p>
<p>Không cần tạo database ^^, nó sẽ tự tạo cho ta 1 db mặc định</p>
<p>Bây giờ hãy thử các query statement sau: (nhớ rằng: thực hịên từng khối lênh cùng loại<br />
thì được, khác loại sẽ gây lỗi.)</p>
<p>create table lop<br />
(<br />
malop integer primary key,<br />
tenlop varchar<br />
)</p>
<p>insert into lop values(1,’Ngoai Ngu’)<br />
insert into lop values(2,’Tin hoc’)<br />
insert into lop values(3,’The Duc’)<br />
insert into lop values(4,’Am Nhac’)</p>
<p>select * from Lop</p>
<p>delete from lop</p>
<p>update lop set tenlop=’cntt’ where malop=2</p>
<p><img class="linked-image" src="http://img2.freeimagehosting.net/uploads/59f58696b6.jpg" border="0" alt="" /></p>
<p>LƯU Ý: MỖI KHI CHAỴ XONG 1 QUERY BẠN MUỐN REFRESH tree view bên trái LẠI THÌ LAM NHƯ SAU:</p>
<p>+ view &#8211; refresh tree hoặc<br />
+ ctrl-R</p>
<p>CSDL trên tồn tại trong bộ nhớ ram, sau khi tắt ứng dụng hsql nó sẽ được giải phóng khỏi ram <img style="vertical-align:middle;" src="http://www.diendantinhoc.com/style_emoticons/default/happy.gif" border="0" alt="happy.gif" />. Nếu có ai hứng thú với hsql, tui sẽ post nhiều chuyên mục khác hấp dẫn hơn có liên quan đến nó.</p>
<p>Đón xem phần kế: lập trình Java kết nối với HSQL</p>
<p>Link: http://kiamiracle.wordpress.com/2008/02/09/h%E1%BB%86-qu%E1%BA%A2n-tr%E1%BB%8A-csdl-hsql/
</p></div>
</div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Head First SQL ]]></title>
<link>http://objsam.wordpress.com/2008/04/22/head-first-sql/</link>
<pubDate>Tue, 22 Apr 2008 05:07:12 +0000</pubDate>
<dc:creator>Syed Aslam</dc:creator>
<guid>http://objsam.wordpress.com/2008/04/22/head-first-sql/</guid>
<description><![CDATA[Head First SQL book, from O&#8217;Reilly, by the Head First team. It simplifies the learning of SQL ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Head First SQL book, from O&#8217;Reilly, by the Head First team. It simplifies the learning of SQL and teaches the language in the easy way.</p>
<p>Download the book from the link below.</p>
<p><a class="aligncenter" href="http://www.fileden.com/files/2007/8/10/1336208/Head%20First%20SQL.pdf" target="_blank">Head First SQL</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Grails - ótima ferramenta para alguns projetos]]></title>
<link>http://blpsilva.wordpress.com/2008/04/19/grails-otima-ferramenta-para-alguns-projetos/</link>
<pubDate>Sat, 19 Apr 2008 15:03:37 +0000</pubDate>
<dc:creator>blpsilva</dc:creator>
<guid>http://blpsilva.wordpress.com/2008/04/19/grails-otima-ferramenta-para-alguns-projetos/</guid>
<description><![CDATA[Atenção, este blog foi migrado para: http://brunopereira.org Toda semana eu e o Silvano discutimos v]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><strong>Atenção, este blog foi migrado para: <a href="http://brunopereira.org" target="_self">http://brunopereira.org</a></strong></p>
<p>Toda semana eu e o Silvano discutimos vários aspectos das nossas aplicações. Como melhorar algumas delas, novos componentes que podem trazer ganhos interessantes, mudanças de arquitetura, etc. Os principais objetivos são: trazer mais qualidade para os projetos e produtividade para a equipe.</p>
<p>Alguns meses atrás estávamos falando com freqüência sobre frameworks web. A maioria das aplicações na Globo ainda usa Struts 1.x. O Struts 1 foi por muitos anos o framework web padrão Java. Ele trouxe muitos ganhos interessantes, comparando com o desenvolvimento usando apenas Servlets + JSP.</p>
<p>Um ponto &#8220;fraco&#8221; do Struts 1 é que ele não tem nenhum suporte a componentes visuais. Toda a parte visual das aplicações fica por conta dos desenvolvedores, assim como os recursos &#8220;Web 2.0&#8243;. O problema é que desenvolver esta parte visual de forma customizada em todos os projetos é muito trabalhosa, não é produtiva. Com isso surgiram inúmeros frameworks mais modernos, com suporte visual muito mais rico, trazendo boa produtividade neste aspecto.</p>
<p>O fato é que com esta enorme gama de opções, não temos mais um framework que se destaque de forma absoluta sobre os outros. Temos várias opções para cada projeto. Entretanto, não dá para querer abraçar o mundo, então é comum que busquemos 1 ou 2 opções que nos atendam em quase todos os casos.</p>
<p>Na nossa equipe nós já temos uma aplicação com JSF, que na verdade foi concebida ano passado, antes da <a href="http://blpsilva.wordpress.com/2008/01/16/java-server-faces-x-wicket-great-framework-of-old-paradigm-vs-new-paradigm/" target="_self">minha mudança de equipe</a>. Eu estou usando o <a href="http://wicket.apache.org" target="_blank">Wicket</a> em um projeto pessoal e ainda estou aprendendo o framework, ainda não o domino a ponto de usá-lo de forma produtiva. Com alguma freqüência nós discutimos sobre estes 2 frameworks, e eu ainda tenho a opinião que <a href="http://blpsilva.wordpress.com/2008/01/16/java-server-faces-x-wicket-great-framework-of-old-paradigm-vs-new-paradigm/" target="_self">descrevi anteriormente</a>.</p>
<p>Neste escopo das discussões sobre JSF vs Wicket, também falamos algumas vezes sobre <a href="http://www.rubyonrails.org/" target="_blank">Rails</a> e <a href="http://grails.org" target="_blank">Grails</a>. Algumas semanas atrás eu e o Silvano começamos a estudar Grails, e fizemos pequenas aplicações de exemplo. Eu já li inteiro <a href="http://www.infoq.com/minibooks/grails" target="_blank">este livro</a> de Grails disponível no <a href="http://www.infoq.com" target="_blank">InfoQ</a>. Ele estava <a href="http://blpsilva.wordpress.com/livros/" target="_self">aqui</a> na minha lista de &#8220;Livros que quero ler quando tiver tempo&#8221;, mas já o movi para a lista de livros que li <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Eu estou gostando bastante do Grails, pois ele é extremamente produtivo para aplicações nas quais eu acho que ele faz sentido. Você consegue em 2 dias desenvolver aplicações que provavelmente você demoraria 1 semana ou mais com frameworks Java tradicionais. Eu ainda não o utilizei o suficiente para saber os limites de uso do mesmo. Provavelmente para projetos com requisitos mais críticos de carga e customização das interfaces, ele já não será uma opção tão boa assim. Entretanto, em aplicações internas, com carga limitada e sem grandes necessidades de customização visual, ele é perfeito.</p>
<p>O próximo passo para mim é tentar utilizá-lo em casos mais complexos. Estou pensando seriamente em utilizá-lo no <a href="http://blpsilva.wordpress.com/2007/11/28/dvogadocom-aprovado-no-javanet/" target="_self">@dvogado.com</a>, um software para advogados que eu desenvolvo no meu tempo vago, mas que está congelado há alguns meses por falta de tempo. Quando eu conseguir um pouco mais de tempo vou tentar implementá-lo com o Grails, e acho que consigo fazer isso bem rapidamente. O Grails atenderia bem à minha proposta de distribuir um pacote completo com tudo que o usuário precisa, <a href="http://blpsilva.wordpress.com/2007/11/21/make-deployments-as-simple-as-possible/" target="_self">tornando o deployment o mais simples possível</a>. Com o Grails eu utilizaria o Jetty + HSQL que ele traz por padrão, e precisaria adicionar apenas o JDK no pacote.</p>
<p>Uma discussão muito interessante também é a de Grails vs Ruby on Rails, mas isso fica para um outro post em breve <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
