java - While(ResultSet.Next() 在第一列条目后跳过,不返回任何数据
问题描述
尝试使用 derby JavaDB 数据库中的条目填充 HashMap,而(rs.next() 在第一列条目后跳过
我尝试将列号更改为列名,更改 ResultSet 查询,连接字符串。
HashMap<String, Student> students = new HashMap();
try
{
Connection conn = DriverManager.getConnection("jdbc:derby://localhost:1527/AceDrivingSchool", "ADC", "ADC");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM ADC.STUDENT");
while(rs.next())
{
String studentId = rs.getString(1);
String emailAddress = rs.getString(2);
String forename = rs.getString(3);
String surname = rs.getString(4);
String addressLine1 = rs.getString(5);
String addressLine2 = rs.getString(6);
String postcode = rs.getString(7);
String telephoneNo = rs.getString(8);
String getGender = rs.getString(9);
char gender = getGender.charAt(0);
String password = rs.getString(11);
boolean isRegistered = rs.getBoolean(12);
boolean isVerified = rs.getBoolean(13);
boolean passedTheory = rs.getBoolean(14);
boolean passedPractical = rs.getBoolean(15);
String drivingLicenseNo = rs.getString(16);
new student //summary
students.put(emailAddress, student);
}
conn.close();
}
catch(Exception ex)
{
String message = ex.getMessage();
}
return students;
}
变量应该显示从数据库中读取的相应数据
解决方案
推荐阅读
- laravel - Laravel:collect() 助手 - 设置集合类型
- excel - 使用 Action Cable 在后台下载导出的 excel 文件
- php - 使用 php 将 mysql 数据转换为带有附加信息的 json
- pyramid - 如何在 Google App 引擎中运行金字塔应用程序
- java - 为什么我收到此错误 No mapping found for HTTP request with URI
- powershell - 使用 powershell 打开多个 rdp 会话
- visual-studio-code - 如何在 VS Code 版本 1.29.1 中将终端窗口停靠在右侧?
- sql - 将 db2 转换为 SQL Server
- ios - 我们可以暂时从 Apple App Store 中隐藏 iOS 应用程序吗?
- groovy - 根据另一组随机数据随机化数据以在 Jmeter 中作为请求正文发送