我们使用java jdk 1.7.0_45,postgresql jdbc connector postgresql-9.3-1100.jdbc41.jar.
以下是我们问题的概要,尽可能多地粘贴下面的代码.
这段代码:
ResultSet rs = DbConn.getInstance().doQuery("Select d.deptId from Depts d");
while (rs.next()){
System.out.println(rs.getInt("d.deptId"));
产生错误:
org.postgresql.util.PSQLException: The column name d.deptId was not found in this ResultSet.
这段代码:
ResultSet rs = DbConn.getInstance().doQuery("Select d.deptId from Depts d");
while (rs.next()){
System.out.println(rs.getInt("deptId"));
不会产生错误.
有没有办法,除了删除"d".从第一个查询,到第一个代码片段不抛出错误消息?
这是源代码:
public class JoinTest {
@Test
public void test(){
boolean pass = false;
try {
ResultSet rs = DbConn.getInstance().doQuery("Select d.deptId from Depts d");
String label = rs.getMetaData().getColumnLabel(1); // What do you get?
System.out.println("label …Run Code Online (Sandbox Code Playgroud)