Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- txtNo = new JTextField();
- {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- String srcurl1 = "jdbc:mysql://localhost:3306/DB_name";
- Connection con = DriverManager.getConnection(srcurl1,"root","paswrd");
- Statement stmt1 = con.createStatement();
- ResultSet rs1 = stmt1.executeQuery("select No from bank where No='"+txtNo.getText()+"' ");
- int ch =rs1.getInt("No");
- int ch4= Integer.parseInt(txtNo.getText());
- if(ch==ch4) // input 58 == 58
- System.out.println("already exits");
- }
- catch(Exception e)
- {
- System.out.println("Exception:"+e);
- }
- }
- while(rs1.next())
- {
- int ch = rs1.getInt("No");
- // ...
- }
- if (rs1.next()) {
- int ch =rs1.getInt("No");
- ...
- }
- Select 1 from bank where No = [your_supplied_value]
- txtNo = new JTextField();
- {
- try {
- String compareText = txtNo.getText().trim();
- if(compareText.length() > 0){
- Class.forName("com.mysql.jdbc.Driver");
- String srcurl1 = "jdbc:mysql://localhost:3306/DB_name";
- Connection con = DriverManager.getConnection(srcurl1,"root","paswrd");
- Statement stmt1 = con.createStatement();
- ResultSet rs1 = stmt1.executeQuery("select 1 from bank where No='"+txtNo.getText()+"' ");
- boolean isPresent = rs1.next();
- if(isPresent){
- System.out.println("Already exists!!");
- }
- }
- }
- catch(Exception e)
- {
- System.out.println("Exception:"+e);
- }
- }
Add Comment
Please, Sign In to add comment