我有一个与此方法相关的问题:st.execute(sql);其中st显然是一个Statement对象.直接来自这个 oracle java教程:
execute:如果查询返回的第一个对象是ResultSet对象,则返回true.如果查询可以返回一个或多个ResultSet对象,请使用此方法.通过重复调用Statement.getResutSet来检索从查询返回的ResultSet对象.
" 一个或多个ResultSet对象 " 是什么意思?一旦得到一个数组,ResultSet怎么可能管理它们?鉴于st.executeQuery(sql)而且st.executeUpdate(sql)非常清楚.它(至少对我来说)的目的不是st.execute(sql)返回一个int,就像它更新了一个表一样.
提前致谢
我有一个以下类,其中一个类型为Long
package com.nm.poc;
public class JSLong{
private Long longValue;
public Long getLongValue() {
return longValue;
}
public void setLongValue(Long longValue) {
this.longValue = longValue;
}
public Long testLongValue(Long longValue){
return longValue;
}
}
Run Code Online (Sandbox Code Playgroud)
我按照以下方式从JavaScript调用方法testLongValue
package com.nm.poc;
import java.util.function.Consumer;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
public class Main {
public static void main(String[] args) throws Exception {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("nashorn");
JSLong jsLong = new JSLong();
//WORKS
engine.put("jsLong", jsLong);
engine.eval("print(jsLong.testLongValue(20))");
//Throws ClassCast Integer to Long
engine.put("jsLong2", (Consumer<Long>)jsLong::testLongValue);
engine.eval("print(jsLong2(20))"); …Run Code Online (Sandbox Code Playgroud) 键=值
这是我要插入和更新的java代码:
if (action.equals("insert")) {
if (con != null) {
if (key == null) {
//session.setAttribute(username, con);
out.println("****Connected Successfully****");
String rootPath=request.getSession().getServletContext().getRealPath("/");
System.out.println(rootPath);
String propPath=rootPath+"/WEB-INF/";
PrintWriter out1 = new PrintWriter(new BufferedWriter(new FileWriter(propPath+"importedDB.properties", true)));
out1.println(cname+"=jdbc:oracle:thin:@"+host+":"+port+"/"+service+","+username+","+password);
out1.close();
} else {
out.println("*Connection name "+cname+" already exists. Please try with another name");
}
}
}
if (action.equals("update")) {
if (con != null) {
if (key == null) {
out.println(cname+" is not available.");
} else {
String rootPath=request.getSession().getServletContext().getRealPath("/");
System.out.println(rootPath);
String propPath=rootPath+"/WEB-INF/";
PrintWriter out1 …Run Code Online (Sandbox Code Playgroud) 我们在Apache2服务器后面运行Tomcat 7,通过AJP连接.
我们在Tomcat上收到的一些AJAX请求不包含任何请求参数.这也适用于GET和POST请求.检查Apache access_log,所有请求的HTTP状态代码均为103:
IP - - [SNIP] "POST /redacted/ticket/1234567 HTTP/1.1" 103 655 "https://redactedhost.com/redacted/ticket/1234567" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"
Run Code Online (Sandbox Code Playgroud)
我无法确定此状态代码的来源.有人听说过吗?据我所知,它不是我们的应用程序的自定义响应,它没有在我们的Tomcat或Apache配置中定义.