求助! ResultSet一直获取不到值
ResultSet一直获取不到值,输出行数为0,可是在access中测试的有一个记录,希望各位大侠给看看
下面是代码:
public class studentjiemian { public studentjiemian(String ch){ try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url="jdbc:odbc:sour"; Connection con=DriverManager.getConnection(url); Statement stmt=con.createStatement(); beijing jFrame = new beijing(); jFrame.setVisible(true); Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); jFrame.setBounds(((int)dimension.getWidth() - 200) / 2, ((int)dimension.getHeight() - 300) / 2, 900, 675); jFrame.setResizable(false); jFrame.setLayout(null); jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel(); label.setBounds(150,20,700,600); JLabel huanying=new JLabel("欢迎你来到学生奖学金管理系统"); huanying.setBounds(50,50,200,30); label.add(huanying); String sqlstr="select username,usercollege,userprofessional from userinf where userid='ch' ";//这个ch是通过另一个类传过来的String值,输出也有值 ResultSet rs=stmt.executeQuery(sqlstr);//rs。next为false。行数也是0 if(rs.next()){ JLabel xingming=new JLabel(rs.getString("username")); xingming.setBounds(50,100,100,30); label.add(xingming); JLabel college=new JLabel(rs.getString("usercollege")); college.setBounds(50,150,100,30); label.add(college); JLabel professional=new JLabel(rs.getString("userprofessional")); professional.setBounds(50,200,100,30); label.add(professional); } jFrame.add(label);