`
sanyecao2314
  • 浏览: 131652 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

EAS主键生成机制

阅读更多

EAS的数据库中有一个自定义函数newbosid,他的传入参数是对应实体的BOSTYPE,输出值是PK.

一般做接口或其他会调用到这个.方式大致如下:

public static void main(String[] paramArrayOfString)
  {
          
        // 加载驱动程序
                try {
                        Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
                        // 得到数据库连接
                        Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@10.195.36.13:1521:kingdee","eas_tst","eas_tst");
                        CallableStatement  cs = conn.prepareCall("{ ?=call newbosid(?)}");
                        // Register the type of the return value
                        cs.registerOutParameter(1, Types.VARCHAR );
                        // Set the value for the IN parameter
                        cs.setString(2,"E91B6727");
                        
                        // Execute and retrieve the returned value
                        for (int i = 0; i < 20; i++) {                                
                                cs.execute();
                                String str = cs.getString(1);
                                System.out.println(str);
                        }
                } catch (InstantiationException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (IllegalAccessException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (ClassNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
  }

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics