#arg

阅读(376) 标签: jdbc, 定义参数,

描述:

通过集算器Jdbc执行多行多列网格代码时用来定义参数。

语法:

  #arg=…

备注:

  集算器Jdbc中执行多行多列网格代码,使用#arg定义参数时,必须写在网格代码的开头位置。

参数:

arg

参数名称。

参数值。

示例:

    定义参数n1的值为2n2的值为3,计算n1+n2的值,如下:

    public void executeQuery1(){

       Connection con = null;

        java.sql.PreparedStatement ps;   

       try{               

          Class.forName("com.esproc.jdbc.InternalDriver");

          con= DriverManager.getConnection("jdbc:esproc:local://");

           String code= "#n1=2\n#n2=3\n=n1+n2";

          Statement st = con.createStatement();

          ResultSet set = st.executeQuery("=" + code);                    

          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);

          }

          }

          }     

    }