我想在 oracle 11g 中插入印度卢比符号。
我试过了:
insert into currency(name, symbol) values ('rupee', unistr('\20B9'));
Run Code Online (Sandbox Code Playgroud)
但它不工作。
SELECT ascii('?') FROM dual; 它为卢比符号提供 ascii 值,但插入后它在行中显示框。
在这里你可以看到
SELECT chr(14844601) FROM dual;
Run Code Online (Sandbox Code Playgroud) 我想以这种方式验证电话号码: -
该字段应允许用户输入字符并应自动更正.因此,"+ 1-908-528-5656"的条目不会为用户创建错误,它只会更改为"19085285656".
我也希望编号在9到11之间.
我也试过下面的代码,但没有得出最终的解决方案:
final String PHONE_REGEX = "^\\+([0-9\\-]?){9,11}[0-9]$";
final Pattern pattern = Pattern.compile(PHONE_REGEX);
String phone = "+1-908-528-5656";
phone=phone.replaceAll("[\\-\\+]", "");
System.out.println(phone);
final Matcher matcher = pattern.matcher(phone);
System.out.println(matcher.matches());
Run Code Online (Sandbox Code Playgroud) 我在 Docker 容器中存在的作业服务器中面临内存泄漏问题。为了分析导致问题的原因,我需要将 jprofiler 或 yourkit 附加到 docker 容器进程。我不知道该怎么做。有人可以解释一下吗?
我在这里有一个问题陈述我需要做什么迭代一个列表找到第一个大于3的整数然后然后加倍并返回它.
这些是一些检查执行操作的方法
public static boolean isGreaterThan3(int number){
System.out.println("WhyFunctional.isGreaterThan3 " + number);
return number > 3;
}
public static boolean isEven(int number){
System.out.println("WhyFunctional.isEven " + number);
return number % 2 == 0;
}
public static int doubleIt(int number){
System.out.println("WhyFunctional.doubleIt " + number);
return number << 1;
}
Run Code Online (Sandbox Code Playgroud)
使用java 8流我可以这样做
List<Integer> integerList = Arrays.asList(1, 2, 3, 5, 4, 6, 7, 8, 9, 10);
integerList.stream()
.filter(WhyFunctional::isGreaterThan3)
.filter(WhyFunctional::isEven)
.map(WhyFunctional::doubleIt)
.findFirst();
Run Code Online (Sandbox Code Playgroud)
而输出是
WhyFunctional.isGreaterThan3 1
WhyFunctional.isGreaterThan3 2
WhyFunctional.isGreaterThan3 3
WhyFunctional.isGreaterThan3 5
WhyFunctional.isEven 5
WhyFunctional.isGreaterThan3 4
WhyFunctional.isEven …Run Code Online (Sandbox Code Playgroud) 我对@JoinColumn和@MappedBy的工作感到困惑.
考虑以下示例这是我的具有单向关系的Department类
@Entity
@Table(name = "DEPARTMENT")
public class Department {
@Id
@Column(name = "DEPARTMENT_ID")
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer departmentId;
@Column(name = "DEPARTMENT_NAME")
private String departmentName;
@Column(name = "LOCATION")
private String location;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "DEPARTMENT_ID")
private List<Employee> employees = new ArrayList<>();
}
Run Code Online (Sandbox Code Playgroud)
我有一个list of employees在Department class上,我已指定@JoinColumn,因此将增加department_id在FK employee table.
但是通过双向关系,我将定义类
Department.java
@Entity
@Table(name = "DEPARTMENT")
public class Department {
@Id
@Column(name = "DEPARTMENT_ID")
@GeneratedValue(strategy = GenerationType.AUTO) …Run Code Online (Sandbox Code Playgroud) 有各种交易传播,例如
REQUIRED- 这是DML操作的情况。
SUPPORTS- 这是查询数据库的情况。
MANDATORY - ?
REQUIRES_NEW - ?
NOT_SUPPORTED - ?
NEVER - ?
NESTED - ?
Run Code Online (Sandbox Code Playgroud)
这些交易传播的现实生活场景有哪些?为什么这些非常适合这种情况?
如果我这样connection.setAutoCommit(false);做会在数据库端创建新的事务,该怎么办?
考虑下面的虚拟代码:
List<Integer> intList = new ArrayList<>();
intList.add(10);
intList.add(20);
intList.add(30);
intList.stream().filter(i -> i > 40)
.throwIf(size of list <= 0)
.collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
java流中是否有任何功能可以实现上述代码?
注意:上面的代码只是我正在做的事情的表示,它不是我正在寻找的确切代码.
下面是要创建的示例代码片段SXSSFWorkbook:
try(SXSSFWorkbook wb = new SXSSFWorkbook()) {
//...
} finally {
wb.dispose(); //wb not accessible over here, so can't use try with resource
}
Run Code Online (Sandbox Code Playgroud)
这里的问题是,如果我将 try 与资源一起使用,则无法dispose() SXSSFWorkbook在 finally 中使用,因为wb在 finally 块中将无法访问变量。
我想知道正在处理删除临时文件所必需的工作簿,或者因为SXSSFWorkbook是AutoCloseable,所以尝试使用资源会处理它。
setAutoCommit为 false 并在关闭连接之前抛出异常,但仍然提交事务。这不是很奇怪的行为吗?
public static void insertEmployee(){
String query1 = "INSERT INTO EMPLOYEE VALUES(80, 'from code')";
String query2 = "INSERT INTO EMPLOYEE VALUES(81, 'from code')";
Connection connection = null;
Statement statement = null;
try {
connection = DriverManager.getConnection(url, username, password);
connection.setAutoCommit(false);
statement = connection.createStatement();
statement.executeUpdate(query1);
ResultSet resultSet = statement.executeQuery(query2);
while(resultSet.next()) //this code throws the exception kept like this intentionally
{
int empNo = resultSet.getInt("EMPLOYEE_ID");
String eName = resultSet.getString("EMPLOYEE_NAME");
System.out.println("eName = " + eName);
}
} catch (SQLException e) { …Run Code Online (Sandbox Code Playgroud) java ×6
autocommit ×2
java-stream ×2
jdbc ×2
apache-poi ×1
connection ×1
docker ×1
exception ×1
executequery ×1
foreign-keys ×1
hibernate ×1
insert ×1
java-8 ×1
oracle ×1
oracle11g ×1
performance ×1
profiler ×1
regex ×1
spring ×1
transactions ×1
validation ×1