Permalink
Browse files

introducing HSQL Database for testing SQL and Hibernate related stuff

  • Loading branch information...
1 parent 3d3325c commit e3c3a68fcb3cab1067db85e705e638cdef0121cf djmamana committed Aug 31, 2008
View
Binary file not shown.
@@ -0,0 +1,17 @@
+#HSQL Database Engine 1.8.0.5
+#Sun Aug 31 18:10:13 ACT 2008
+hsqldb.script_format=0
+runtime.gc_interval=0
+sql.enforce_strict_size=false
+hsqldb.cache_size_scale=8
+readonly=false
+hsqldb.nio_data_file=true
+hsqldb.cache_scale=14
+version=1.8.0
+hsqldb.default_table_type=memory
+hsqldb.cache_file_scale=1
+hsqldb.log_size=200
+modified=yes
+hsqldb.cache_version=1.7.0
+hsqldb.original_version=1.8.0
+hsqldb.compatible_version=1.8.0
@@ -0,0 +1 @@
+java -cp %M2_REPO%/hsqldb/hsqldb/1.8.0.7/hsqldb-1.8.0.7.jar org.hsqldb.util.DatabaseManager
@@ -2,15 +2,32 @@
import java.sql.Connection;
import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
import java.sql.SQLException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
public class HSQLTest {
-
+ protected static final Log log = LogFactory.getLog(HSQLTest.class);
+
+ public final String TEST_DB_PATH = "target/test-classes/hsql/test_dj_db"; //For read-only purposes
+
public static void main(String[] args) throws SQLException, ClassNotFoundException {
Class.forName("org.hsqldb.jdbcDriver" );
-
- Connection c = DriverManager.getConnection("jdbc:hsqldb:file:test_dj_db", "sa", "");
-
+ Connection c = DriverManager.getConnection("jdbc:hsqldb:file:target/test-classes/hsql/test_dj_db", "sa", "");
+
+ PreparedStatement ps = c.prepareStatement("SELECT * FROM Customer");
+ ResultSet rs = ps.executeQuery();
+ while (rs.next()) {
+ log.info(rs.getString("firstname")+ ", " + rs.getString("lastname"));
+ }
+
+ rs.close();
+ ps.close();
+ c.close();
+
}
}
Binary file not shown.
@@ -0,0 +1,17 @@
+#HSQL Database Engine 1.8.0.5
+#Sun Aug 31 18:04:13 ACT 2008
+hsqldb.script_format=0
+runtime.gc_interval=0
+sql.enforce_strict_size=false
+hsqldb.cache_size_scale=8
+readonly=false
+hsqldb.nio_data_file=true
+hsqldb.cache_scale=14
+version=1.8.0
+hsqldb.default_table_type=memory
+hsqldb.cache_file_scale=1
+hsqldb.log_size=200
+modified=yes
+hsqldb.cache_version=1.7.0
+hsqldb.original_version=1.8.0
+hsqldb.compatible_version=1.8.0

0 comments on commit e3c3a68

Please sign in to comment.