Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

jdbc program..using hashMap

807605Oct 15 2007 — edited Oct 17 2007
public Map userprivss(int usercode){
Map data=null;
try{
con=getconnection();
data=new HashMap();
pstmt=con.prepareStatement("select privs from PRIV_USERS where ucode=?");
pstmt.setInt(1,usercode);
rs=pstmt.executeQuery();
while(rs.next())
{
data.put(rs.getString(1),rs.getString(1));
}
}catch(Exception e){
e.printStackTrace();
System.out.println ("exception in select statement" +e.getMessage());
}
System.out.println("(((((((((((((()))))))))))))))))" +data);
return data;
}

public static void main(String args[])
{
checkselect ch=new checkselect();
int ucode=1;
Map selectvals=null;
selectvals=new HashMap();
selectvals=ch.userprivss(ucode);
System.out.println(selectvals);

i dont knw why itz not printing out data.it keeps saying exception in select statement ,no data found..i really need a quick answer..thankyou in advance..
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 14 2007
Added on Oct 15 2007
38 comments
553 views