我是数据库的新手,最近开始编写H2数据库的测试用例.我想知道如何在Eclipse中测试存储过程.我见过以下内容:
http://www.h2database.com/html/features.html#user_defined_functions
h2database链接中给出的示例代码,
"CREATE ALIAS NEXT_PRIME AS $$
String nextPrime(String value) {
return new BigInteger(value).nextProbablePrime().toString();
}
$$;
"
Run Code Online (Sandbox Code Playgroud)
应该在哪里宣布?以及如何运行它?
PS - 我有H2 JAR文件并正在测试它.
如果有人可以告诉我如何在Java中为H2编写一个简单的存储过程,那将会有很大的帮助.
在H2中还有以下任何等价物吗?
"开始dbms_output"?
谢谢.
我有以下代码可以工作,但我只是想知道在Jsoup中是否有可能找出错误的确切原因.
以下返回true(如预期的那样)
private void validateProtocol() {
String html = "<p><a href='https://example.com/'>Link</a></p>";
Whitelist whiteList = Whitelist.basic();
whiteList.addProtocols("a","href","tel");
whiteList.removeProtocols("a","href","ftp");
boolean safe = Jsoup.isValid(html, whiteList);
System.out.println(safe);
}
Run Code Online (Sandbox Code Playgroud)
当我将上面的字符串更改为它返回false(按预期)
String html = "<p><a href='ftp://example.com/'>Link</a></p>";
Run Code Online (Sandbox Code Playgroud)
现在,当我有以下代码时,有两个错误,一个是无效协议,一个是onfocus()链接.
private void validateProtocol() {
String html = "<p><a href='ftp://example.com/' onfocus='invalidLink()'>Link</a></p>";
Whitelist whiteList = Whitelist.basic();
whiteList.addProtocols("a","href","tel", "device");
whiteList.removeProtocols("a","href","ftp");
boolean safe = Jsoup.isValid(html, whiteList);
System.out.println(safe);
}
Run Code Online (Sandbox Code Playgroud)
结果是假的,但有没有办法弄清楚URL的哪一部分是假的?例如 - 错误的协议或错误的方法..?
我试图使用BigDecimal显示百分比.
例如,如果我必须这样做
double val = (9522 / total ) * 100;
System.out.println("Val is :" + val);
Run Code Online (Sandbox Code Playgroud)
总计120000.
我想将计算显示为百分比,但由于计算结果为小于0的值,我无法显示百分比
我也试过了
BigDecimal decimal = new BigDecimal((9522 * 100 ) / total);
BigDecimal roundValue = decimal.setScale(2, BigDecimal.ROUND_HALF_UP);
System.out.println("decimal: " + decimal);
System.out.println("roundValue: " + roundValue);
Run Code Online (Sandbox Code Playgroud)
但结果相同.
即使是小数,我怎么能显示百分比?