
i made a table named result having two fields 1>rollno 2>marks i creates a gui where i use a textfield and two buttons "ok" and "cancel" i want to take input from textfield as an integer(rollno) and the marks associated with that must be displayed.i write the following code but the error appears is "no specific value for parameter 1" so please suggest me where t am wrong. coding written in "ok" button
public void actionPerformed(ActionEvent e){ if(e.getSource()==b1){ try{
Class.forName("com.mysql.jdbc.Driver");
Connection cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb" +
"?user=root&password=lalit&database=mydb");
String url="select marks from student where rollno=?";
PreparedStatement stmt=cn.prepareStatement(url);
ResultSet rs=stmt.executeQuery();
stmt.setString(1,tf1.getText().toString());
int n=Integer.parseInt(rs.getString(2));
System.out.println("Your marks is "+ n); stmt.close(); cn.close(); } catch(Exception ex){ JOptionPane.showMessageDialog(null, ex);
}
}
if(e.getSource()==b2){ this.dispose();
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.