如何在两个方法之间传递参数public void getseq() throws SQLException {
Connection conn = DBAccess.getInstance().getConnection();
PreparedStatement pstm = null;
PreparedStatement pstm1= null;
try {
pstm = conn.prepareStatement("selcet seq.nextval from XW ");
pstm1 = conn.prepareStatement("selcet seq.nextval from XW_FJ ");
ResultSet rs = pstm.executeQuery();
int a = rs.getInt(1);
int b = rs.getInt(2);
}catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void insertXW(int a ,int b){。要把前一个方法的两个值给下一个方法。
Connection conn = DBAccess.getInstance().getConnection();
PreparedStatement pstm = null;
PreparedStatement pstm1= null;
try {
pstm = conn.prepareStatement("selcet seq.nextval from XW ");
pstm1 = conn.prepareStatement("selcet seq.nextval from XW_FJ ");
ResultSet rs = pstm.executeQuery();
int a = rs.getInt(1);
int b = rs.getInt(2);
}catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void insertXW(int a ,int b){。要把前一个方法的两个值给下一个方法。
pstm = conn.prepareStatement("selcet seq.nextval from XW ");
pstm1 = conn.prepareStatement("selcet seq.nextval from XW_FJ ");
ResultSet rs = pstm.executeQuery();
int a = rs.getInt(1);
int b = rs.getInt(2);
insertXW(a,b)}catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
int a = 0;
int b = 0;
public void getseq() throws SQLException {
Connection conn = DBAccess.getInstance().getConnection();
PreparedStatement pstm = null;
PreparedStatement pstm1= null;
try {
pstm = conn.prepareStatement("selcet seq.nextval from XW ");
pstm1 = conn.prepareStatement("selcet seq.nextval from XW_FJ ");
ResultSet rs = pstm.executeQuery();
a = rs.getInt(1);
b = rs.getInt(2); }catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace(); } } public void insertXW(int a ,int b){
。
int a = 0;
int b = 0;
list.add(a);
list.add(b);return list;
下面是我改写后的程序import java.util.List;public List<int> getseq() throws SQLException {
Connection conn = DBAccess.getInstance().getConnection();
PreparedStatement pstm = null;
PreparedStatement pstm1= null;
try {
pstm = conn.prepareStatement("selcet seq.nextval from XW ");
pstm1 = conn.prepareStatement("selcet seq.nextval from XW_FJ ");
ResultSet rs = pstm.executeQuery();
int a = rs.getInt(1);
int b = rs.getInt(2);
List<int> list=new List<int>();
list.add(a);
list.add(b);
return list;}catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}public void insertXW(int a ,int b){
}