0

我正在编写一个应用程序,该应用程序需要从 oracle 数据库中查询数据并将每个查询的数据作为输入发送到 java 中的另一个函数。我不确定如何将这些查询的数据作为输入传递给另一个函数。我正在尝试使用 Arraylist 但仍然无法作为输入传递。任何帮助将不胜感激。希望收到大家的来信。

    String dbuserName = "";
    String dbpassword = "";
    String url = "jdbc:oracle:thin:@//xxxxxxxxxxxxxx";
    String driverName = "oracle.jdbc.driver.OracleDriver";
    Connection conn = null;
    Session session = null;

    try{
        // Some Connection code to database here before  below code 
        Statement stmt = conn.createStatement();
        ResultSet rs = stat.executeQuery( "SELECT ..." );
        ArrayList <String[]> result = new ArrayList<String[]>();
        /*Queried data has only one column, that is useid, now need to
        send each id as input to below try/catch statement*/                
        try {
                userManager.enable(USER_LOGIN, true);
                System.out.print("\n Enabled user Successfully");                                               
        } catch (ValidationFailedException e) {
            e.printStackTrace();
            logger.severe("ValidationFailedException: " + e ");
        }
4

1 回答 1

0

这将帮助你

while (rs.next()) {              
        int i = 1;
        result.add(rs.getString(i++));
}

然后在for循环中

for(int i=0;i<result.size()-1;i++)
{
     String USER_LOGIN=result.get(i);
    userManager.enable(USER_LOGIN, true);
}
于 2017-03-08T12:56:30.523 回答