Java examples for JDBC:Derby
Connect to derby database
/**// ww w . j a v a2 s . c om * * @author ARUN */ import java.sql.*; import java.util.logging.Level; import java.util.logging.Logger; import java.util.*; import javax.swing.JFrame; public class ForgotPassword extends javax.swing.JFrame { private Connection conn; private Statement stmt; private ResultSet rs; private String uname; public ForgotPassword(String uname) { initComponents(); conn = null; stmt = null; rs = null; try { Class.forName("org.apache.derby.jdbc.ClientDriver"); } catch (ClassNotFoundException e) { System.out.println("Class not found " + e); } System.out.println("JDBC Class found"); try { conn = DriverManager .getConnection("jdbc:derby://localhost:1527//JD", "arunjd_07", "jagan"); stmt = conn.createStatement(); } catch (SQLException e) { System.out.print("conn" + e.getMessage()); } this.uname = uname; try { rs = stmt .executeQuery("select ques from tourist where uname like '" + uname + "'"); rs.next(); jLabel3.setText(rs.getString("ques")); } catch (SQLException ex) { Logger.getLogger(ForgotPassword.class.getName()).log( Level.SEVERE, null, ex); } }