提交 b4232f24 authored 作者: Thomas Mueller's avatar Thomas Mueller

Improved documentation

上级 e584183b
......@@ -44,31 +44,31 @@ public class Mode {
/**
* When converting the scale of decimal data, the number is only converted
* if the new scale is smaller then current scale. Usually, the scale is
* if the new scale is smaller than the current scale. Usually, the scale is
* converted and 0s are added if required.
*/
public boolean convertOnlyToSmallerScale;
/**
* Creating indexes in the CREATE TABLE statement should be supported.
* Creating indexes in the CREATE TABLE statement is allowed.
*/
public boolean indexDefinitionInCreateTable;
/**
* The identifiers should be returned in lower case.
* Meta data calls return identifiers in lower case.
*/
public boolean lowerCaseIdentifiers;
/**
* Concatenation of a NULL with another value results in NULL. Usually, the
* NULL is treated as an empty string if only one of the operators is NULL,
* and NULL is only returned if both values are NULL.
* Concatenation with NULL results in NULL. Usually, NULL is treated as an
* empty string if only one of the operands is NULL, and NULL is only
* returned if both operands are NULL.
*/
public boolean nullConcatIsNull;
/**
* When converting a floating point number to a integer, the fractional
* digits should not be truncated, but the value should be rounded.
* When converting a floating point number to an integer, the fractional
* digits are not truncated, but the value is rounded.
*/
public boolean roundWhenConvertToLong;
......@@ -79,12 +79,12 @@ public class Mode {
/**
* Support for the syntax [OFFSET .. ROW] [FETCH ... ONLY]
* as an alternative syntax for LIMIT .. OFFSET.
* as an alternative for LIMIT .. OFFSET.
*/
public boolean supportOffsetFetch;
/**
* The system columns 'CTID' and 'OID' should be supported.
* The system columns 'CTID' and 'OID' are supported.
*/
public boolean systemColumns;
......
......@@ -49,7 +49,8 @@ public class Compact {
* @param user the user name
* @param password the password
*/
public static void compact(String dir, String dbName, String user, String password) throws SQLException {
public static void compact(String dir, String dbName,
String user, String password) throws SQLException {
String url = "jdbc:h2:" + dir + "/" + dbName;
String file = "data/test.sql";
Script.execute(url, user, password, file);
......
......@@ -55,9 +55,19 @@ public class Function {
new Integer[] { new Integer(30), new Integer(20) });
prep.setObject(2,
new Integer[] { new Integer(1), new Integer(2) });
ResultSet rs2 = prep.executeQuery();
while (rs2.next()) {
System.out.println(rs2.getInt(1));
rs = prep.executeQuery();
while (rs.next()) {
System.out.println(rs.getInt(1));
}
// Using a custom function like table
stat.execute("CREATE ALIAS MATRIX FOR \"org.h2.samples.Function.getMatrix\" ");
prep = conn.prepareStatement("SELECT * FROM MATRIX(?) " +
"ORDER BY X, Y");
prep.setInt(1, 2);
rs = prep.executeQuery();
while (rs.next()) {
System.out.println(rs.getInt(1) + "/" + rs.getInt(2));
}
conn.close();
......@@ -97,4 +107,29 @@ public class Function {
return rs;
}
/**
* Creates a simple result set with two columns.
*
* @param conn the connection
* @param size the number of x and y values
* @return the result set with two columns
*/
public static ResultSet getMatrix(Connection conn, Integer size)
throws SQLException {
SimpleResultSet rs = new SimpleResultSet();
rs.addColumn("X", Types.INTEGER, 10, 0);
rs.addColumn("Y", Types.INTEGER, 10, 0);
String url = conn.getMetaData().getURL();
if (url.equals("jdbc:columnlist:connection")) {
return rs;
}
for (int s = size.intValue(), x = 0; x < s; x++) {
for (int y = 0; y < s; y++) {
rs.addRow(new Object[] {
new Integer(x), new Integer(y) });
}
}
return rs;
}
}
......@@ -131,6 +131,11 @@ public class TaskProcess {
process.destroy();
}
/**
* Trace the operation. Tracing is disabled by default.
*
* @param s the string to print
*/
private void traceOperation(String s) {
// ignore
}
......
......@@ -46,7 +46,7 @@ public class TestSampleApps extends TestBase {
+ "PHONE: +41123456789\n\n" + "NAME: John Jones\n" + "EMAIL: john.jones@abcde.abc\n"
+ "PHONE: +41976543210\n");
testApp(org.h2.samples.Function.class, null,
"2 is prime\n3 is prime\n5 is prime\n7 is prime\n11 is prime\n13 is prime\n17 is prime\n19 is prime\n30\n20");
"2 is prime\n3 is prime\n5 is prime\n7 is prime\n11 is prime\n13 is prime\n17 is prime\n19 is prime\n30\n20\n0/0\n0/1\n1/0\n1/1");
// Not compatible with PostgreSQL JDBC driver (throws a NullPointerException)
//testApp(org.h2.samples.SecurePassword.class, null, "Joe");
// TODO test ShowProgress (percent numbers are hardware specific)
......
......@@ -586,4 +586,4 @@ soerensen favicon glass restarts flexive fish resulted vpda mvc kotek jan
consistently springfuse grep signatures wrote symbolic parents caches readers
animate scaladoc models disadvantages vladykin sergi trims requesting
handing bonita placed euros embeds reliability singular unregister quotas
overall httpdocs tigris eclemma
\ No newline at end of file
overall httpdocs tigris eclemma separates
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论