Hi all, I am working on SQL Server 2000 DataBase ,Tomcat 3.2.2,JSP in Visual Age for Java.When I try to put the data into a hashtable after fetching from the database it returns null in the hashtable.Pl. help.I am tottally stuck up.
System.out.println(RS.getInt(1))// I get the output. ht1.put("AC_userid", new Integer(RS.getInt(1)).toString()); ht1.put("AC_userlogin",RS.getString(2)); ht1.put("AC_password",RS.getString(3)); ht1.put("AC_accesstype",RS.getString(4));
if(pstmt8!=null) { pstmt8.close(); } } catch (Exception e1){} } return null; } I am able to print the value of rs.getInt(1) in the loop.But still the hashtable returns a null. Bye..
Shiva Kumar
Ranch Hand
Joined: Feb 09, 2001
Posts: 30
posted
0
Hi
1. java.sql.ResultSet RS = pstmt8.executeQuery(); 2. RS.next(); 3. if(RS.next()) 4. { 5. ***System.out.println(RS.getInt(1))// I get the output. 6. ***ht1.put("AC_userid", new Integer(RS.getInt(1)).toString()); 7. ht1.put("AC_userlogin",RS.getString(2)); 8. ht1.put("AC_password",RS.getString(3)); 9. ht1.put("AC_accesstype",RS.getString(4)); 10. } 11. RS.close(); After Getting First String from ResultSet, not possible to get the Same once again. You did that in Line No.5 and 6. Just Remove Line No.5 and Execute. It will work. Another thing in Line 2. you just put RS.next() suppose if your Query return more than One Row you will get the Loaded Hashtable other wise also you will get null. Shiva.
Frank Carver
Sheriff
Joined: Jan 07, 1999
Posts: 6913
posted
0
"Bhuvana B", The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements. Thanks.
1. java.sql.ResultSet RS = pstmt8.executeQuery(); 2. RS.next(); 3. if(RS.next()) 4. { 5. ***System.out.println(RS.getInt(1))// I get the output. 6. ***ht1.put("AC_userid", new Integer(RS.getInt(1)).toString()); 7. ht1.put("AC_userlogin",RS.getString(2)); 8. ht1.put("AC_password",RS.getString(3)); 9. ht1.put("AC_accesstype",RS.getString(4)); 10. } 11. RS.close(); After Getting First String from ResultSet, not possible to get the Same once again. You did that in Line No.5 and 6. Just Remove Line No.5 and Execute. It will work. Another thing in Line 2. you just put RS.next() suppose if your Query return more than One Row you will get the Loaded Hashtable other wise also you will get null. Shiva.
A Agrawal
Ranch Hand
Joined: Jul 13, 2001
Posts: 41
posted
0
By the way, which JDBC are you using ? if you use JDBC 2.0+ (3.0 is also available), You won't face this problem. ------------------ Amit Agrawal, New Delhi, India.
Amit Agrawal,<BR>New Delhi, India.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.