想从sql中读取多行数据,然后存储到java中的数组或是list上面 50
可是只会读取一行数据,多行数据不知道怎么读我写的代码是这样的:LinkToSql(){Stringdriver="com.microsoft.sqlserver.jdbc...
可是只会读取一行数据,多行数据不知道怎么读
我写的代码是这样的:
LinkToSql() { String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; String url = "jdbc:sqlserver://localhost\\MSSQLSERVER:1433;databaseName=InforDB"; String username = "sa"; String password = "123456";
try { Class.forName(driver); Connection conn = DriverManager.getConnection(url, username, password); stmt = conn.createStatement(); //rs = stmt.executeQuery("update Table1 set Sno =" + 7733380); rs = stmt.executeQuery("select * from Data_ticket where flight_number='BH001' and flight_time = '2015-04-29 8:00:00'"); while (rs.next()) { for (int i = 0; i < note.length; i++) { note[i] = rs.getObject(i + 1); } } balance = Double.parseDouble(note[money_].toString()); } catch (Exception ex) { } } 展开
我写的代码是这样的:
LinkToSql() { String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; String url = "jdbc:sqlserver://localhost\\MSSQLSERVER:1433;databaseName=InforDB"; String username = "sa"; String password = "123456";
try { Class.forName(driver); Connection conn = DriverManager.getConnection(url, username, password); stmt = conn.createStatement(); //rs = stmt.executeQuery("update Table1 set Sno =" + 7733380); rs = stmt.executeQuery("select * from Data_ticket where flight_number='BH001' and flight_time = '2015-04-29 8:00:00'"); while (rs.next()) { for (int i = 0; i < note.length; i++) { note[i] = rs.getObject(i + 1); } } balance = Double.parseDouble(note[money_].toString()); } catch (Exception ex) { } } 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询