Java可以调用它的存储过程,你用存储过程写一下;具体的调用方法去查查MSDN,我只会Oracle的

解决方案 »

  1.   

    一样的啊,
     大致是这样的        Connection conn=null;
            String qs = null;        try {
                Class.forName(driver).newInstance();            conn=DriverManager.getConnection(url,"sa","");
                qs="select ID,dbo.getOnlineTime(NowTime) as 'online' from Tablename where.....";
                PreparedStatement stmt = conn.prepareStatement(qs);
                //stmt.setString(1,"B"); //set value of  parameter ,if needed
                ResultSet rs = stmt.executeQuery();
                while( rs.next()){
                    System.out.println(rs.getString(1));
               }
               rs.close();
               conn.close();
                conn=null;
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (SQLException e) {
                e.printStackTrace();
            } finally{
                if (conn!=null){
                    try{
                        conn.close();
                        conn = null;
                }catch(Exception ex){}
                }