描述:
集算器JDBC执行语句中的参数。
备注:
集算器JDBC执行语句中的参数,与eval()规则相同,通过i指定参数位置,?0表示所有参数构成的序列。
参数:
i |
参数位置。 |
示例:
public void cs(){
Connection con = null;
try{
//建立连接
Class.forName("com.esproc.jdbc.InternalDriver");
con= DriverManager.getConnection("jdbc:esproc:local://");
String code="?2/?1";
PreparedStatement pst = con.prepareStatement("="+code);
pst.setObject(1,3);
pst.setObject(2,6);
ResultSet set = pst.executeQuery();
ResultSetMetaData meta = set.getMetaData();
while (set.next()) {
for(int i=0; i<meta.getColumnCount(); i++){
System.out.print(set.getObject(i+1) + "\t");
}
System.out.println();
}
}
catch(Exception e){
System.out.println(e);
}
finally{
//关闭连接
if (con!=null) {
try {
con.close();
}
catch(Exception e) {
System.out.println(e);
}
}
}
}
以上代码中,第1个参数值为3,第2个参数值为6,执行语句=?2/?1相当于计算=6/3,返回结果为2.0;当定义String code="?0"时,返回结果为[3,6]。