Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Power Lifting Lever Belt
SkullVamp
Updated:
Saturday at 10:32 PM
Ad icon
port.lk Domain for sale
Lankan-Tech
Updated:
Saturday at 3:55 PM
Colombo
Kaduwela - Two Storey House for Sale
dilrasan
Updated:
Thursday at 2:23 PM
Ad icon
Wechat qr verification
Pawan2005
Updated:
Thursday at 1:28 AM
🚀 GOOGLE AI PRO 18 MONTHS ACTIVATION 🚀
sayuru bandara
Updated:
Wednesday at 5:34 PM
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
netbeans login help
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="rudr@" data-source="post: 20905868" data-attributes="member: 315778"><p>package interfac;</p><p></p><p>import com.mysql.jdbc.Connection;</p><p>import com.mysql.jdbc.PreparedStatement;</p><p>import java.awt.HeadlessException;</p><p>import java.sql.ResultSet;</p><p>import java.sql.SQLException;</p><p>import javax.swing.JOptionPane;</p><p>import mycode.dbconnect;</p><p></p><p></p><p>public class login extends javax.swing.JFrame {</p><p> </p><p> Connection con = null;</p><p> <span style="color: Red"> PreparedStatement pst = null;</span></p><p> ResultSet rs=null;</p><p> </p><p> </p><p></p><p> /**</p><p> * Creates new form login</p><p> */</p><p> public login() {</p><p> initComponents();</p><p> </p><p> // connect to db</p><p> con = dbconnect.connect();</p><p> }</p><p> </p><p> </p><p></p><p> /**</p><p> * This method is called from within the constructor to initialize the form.</p><p> * WARNING: Do NOT modify this code. The content of this method is always</p><p> * regenerated by the Form Editor.</p><p> */</p><p> @SuppressWarnings("unchecked")</p><p> // <editor-fold defaultstate="collapsed" desc="Generated Code"> </p><p> private void initComponents() {</p><p></p><p> jLabel1 = new javax.swing.JLabel();</p><p> jLabel2 = new javax.swing.JLabel();</p><p> jButton1 = new javax.swing.JButton();</p><p> uname1 = new javax.swing.JTextField();</p><p> password1 = new javax.swing.JTextField();</p><p></p><p> setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);</p><p> addWindowListener(new java.awt.event.WindowAdapter() {</p><p> public void windowOpened(java.awt.event.WindowEvent evt) {</p><p> formWindowOpened(evt);</p><p> }</p><p> });</p><p></p><p> jLabel1.setText("user name");</p><p></p><p> jLabel2.setText("password");</p><p></p><p> jButton1.setText("Login");</p><p> jButton1.addMouseListener(new java.awt.event.MouseAdapter() {</p><p> public void mouseClicked(java.awt.event.MouseEvent evt) {</p><p> jButton1MouseClicked(evt);</p><p> }</p><p> });</p><p> jButton1.addActionListener(new java.awt.event.ActionListener() {</p><p> public void actionPerformed(java.awt.event.ActionEvent evt) {</p><p> jButton1ActionPerformed(evt);</p><p> }</p><p> });</p><p></p><p> javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());</p><p> getContentPane().setLayout(layout);</p><p> layout.setHorizontalGroup(</p><p> layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)</p><p> .addGroup(layout.createSequentialGroup()</p><p> .addGap(106, 106, 106)</p><p> .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)</p><p> .addComponent(jLabel2)</p><p> .addComponent(jLabel1))</p><p> .addGap(60, 60, 60)</p><p> .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)</p><p> .addComponent(jButton1)</p><p> .addComponent(uname1, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)</p><p> .addComponent(password1, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE))</p><p> .addContainerGap(268, Short.MAX_VALUE))</p><p> );</p><p> layout.setVerticalGroup(</p><p> layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)</p><p> .addGroup(layout.createSequentialGroup()</p><p> .addGap(104, 104, 104)</p><p> .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)</p><p> .addComponent(jLabel1)</p><p> .addComponent(uname1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))</p><p> .addGap(41, 41, 41)</p><p> .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)</p><p> .addComponent(jLabel2)</p><p> .addComponent(password1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))</p><p> .addGap(46, 46, 46)</p><p> .addComponent(jButton1)</p><p> .addContainerGap(160, Short.MAX_VALUE))</p><p> );</p><p></p><p> pack();</p><p> }// </editor-fold> </p><p></p><p> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> } </p><p></p><p> private void jButton1MouseClicked(java.awt.event.MouseEvent evt) { </p><p> </p><p> String sql;</p><p> sql = "select * from studentreg where uname = ? and password = ?";</p><p> try</p><p> {</p><p> pst = (PreparedStatement) con.prepareStatement(sql);</p><p> pst.setString(1, uname1.getText());</p><p> pst.setString(2, password1.getText());</p><p> rs = pst.executeQuery();</p><p> if (rs.next())</p><p> {</p><p> JOptionPane.showMessageDialog(null, "Username and Password correct");</p><p> close();</p><p> </p><p> main s= new main();</p><p> s.setVisible(true);</p><p> }</p><p> else</p><p> {</p><p> JOptionPane.showMessageDialog(null, "invalid username and password");</p><p> }</p><p> }</p><p> catch (HeadlessException | SQLException e)</p><p> {</p><p> JOptionPane.showMessageDialog(null, e);</p><p> }</p><p> </p><p> </p><p> } </p><p></p><p> private void formWindowOpened(java.awt.event.WindowEvent evt) { </p><p> </p><p> con = dbconnect.connect();</p><p> } </p><p></p><p> /**</p><p> * @param args the command line arguments</p><p> */</p><p> public static void main(String args[]) {</p><p> </p><p> </p><p> </p><p> </p><p></p><p> /* Set the Nimbus look and feel */</p><p> //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "></p><p> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.</p><p> * For details see <a href="http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html" target="_blank">http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html</a> </p><p> */</p><p> try {</p><p> for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {</p><p> if ("Nimbus".equals(info.getName())) {</p><p> javax.swing.UIManager.setLookAndFeel(info.getClassName());</p><p> break;</p><p> }</p><p> }</p><p> } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {</p><p> java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);</p><p> }</p><p> //</editor-fold></p><p> </p><p> //</editor-fold></p><p></p><p> /* Create and display the form */</p><p> java.awt.EventQueue.invokeLater(() -> {</p><p> new login().setVisible(true);</p><p> });</p><p> }</p><p></p><p> // Variables declaration - do not modify </p><p> private javax.swing.JButton jButton1;</p><p> private javax.swing.JLabel jLabel1;</p><p> private javax.swing.JLabel jLabel2;</p><p> private javax.swing.JTextField password1;</p><p> private javax.swing.JTextField uname1;</p><p> // End of variables declaration </p><p></p><p> private void close() {</p><p> </p><p> </p><p> throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.</p><p> }</p><p>}</p><p></p><p></p><p>hadala bn thiyenne,</p></blockquote><p></p>
[QUOTE="rudr@, post: 20905868, member: 315778"] package interfac; import com.mysql.jdbc.Connection; import com.mysql.jdbc.PreparedStatement; import java.awt.HeadlessException; import java.sql.ResultSet; import java.sql.SQLException; import javax.swing.JOptionPane; import mycode.dbconnect; public class login extends javax.swing.JFrame { Connection con = null; [COLOR="Red"] PreparedStatement pst = null;[/COLOR] ResultSet rs=null; /** * Creates new form login */ public login() { initComponents(); // connect to db con = dbconnect.connect(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); uname1 = new javax.swing.JTextField(); password1 = new javax.swing.JTextField(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); addWindowListener(new java.awt.event.WindowAdapter() { public void windowOpened(java.awt.event.WindowEvent evt) { formWindowOpened(evt); } }); jLabel1.setText("user name"); jLabel2.setText("password"); jButton1.setText("Login"); jButton1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton1MouseClicked(evt); } }); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(106, 106, 106) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2) .addComponent(jLabel1)) .addGap(60, 60, 60) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton1) .addComponent(uname1, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(password1, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(268, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(104, 104, 104) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(uname1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(41, 41, 41) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(password1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(46, 46, 46) .addComponent(jButton1) .addContainerGap(160, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { } private void jButton1MouseClicked(java.awt.event.MouseEvent evt) { String sql; sql = "select * from studentreg where uname = ? and password = ?"; try { pst = (PreparedStatement) con.prepareStatement(sql); pst.setString(1, uname1.getText()); pst.setString(2, password1.getText()); rs = pst.executeQuery(); if (rs.next()) { JOptionPane.showMessageDialog(null, "Username and Password correct"); close(); main s= new main(); s.setVisible(true); } else { JOptionPane.showMessageDialog(null, "invalid username and password"); } } catch (HeadlessException | SQLException e) { JOptionPane.showMessageDialog(null, e); } } private void formWindowOpened(java.awt.event.WindowEvent evt) { con = dbconnect.connect(); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see [url]http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html[/url] */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(() -> { new login().setVisible(true); }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JTextField password1; private javax.swing.JTextField uname1; // End of variables declaration private void close() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } } hadala bn thiyenne, [/QUOTE]
Insert quotes…
Verification
Haya warak paha keeyada? (haya wadi kireema paha)
Post reply
Top
Bottom