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
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
Saturday at 11:44 PM
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
Java 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="niyomax" data-source="post: 19016541" data-attributes="member: 514695"><p>meka kohomada balanna kauruhari (weda karanawa) mam keewe standard eka <img src="/styles/default/xenforo/smilies/default/P.gif" class="smilie" loading="lazy" alt=":P" title=":P :P" data-shortname=":P" /></p><p></p><p>DB Class</p><p></p><p>[CODE]package elakiri;</p><p>import java.sql.Connection;</p><p>import java.sql.DriverManager;</p><p>import java.sql.SQLException;</p><p></p><p>public class DBClass {</p><p> private static final String USERNAME= "root";</p><p> private static final String PASSWORD= "";</p><p> private static final String CONN_STRING= "jdbc:mysql://localhost:3306/exampleelakiri";</p><p> </p><p> public static Connection ConnectDB() throws SQLException{</p><p> </p><p> Connection conn=null;</p><p> </p><p> try{</p><p> conn=DriverManager.getConnection(CONN_STRING,USERNAME,PASSWORD);</p><p> return conn;</p><p> }catch(SQLException e){</p><p> System.err.println(e);</p><p> </p><p> }</p><p> return null;</p><p> }</p><p></p><p> </p><p>}[/CODE]</p><p></p><p>login class ekema</p><p>[CODE]</p><p>public class LoginForm extends javax.swing.JFrame {</p><p>Connection conn=null;</p><p>ResultSet rs=null;</p><p>PreparedStatement pst=null;</p><p></p><p> public LoginForm() throws SQLException {</p><p> initComponents();</p><p> conn= DBClass.ConnectDB();</p><p> }[/CODE]</p><p></p><p>Button</p><p>Action Perfomed ekata</p><p></p><p> [CODE] private void cmd_loginActionPerformed(java.awt.event.ActionEvent evt) { </p><p> String sql = "SELECT * from adminstbl where username=? and password=?";</p><p> try{</p><p> pst=conn.prepareStatement(sql);</p><p> pst.setString(1, uname.getText());</p><p> pst.setString(2, pword.getText());</p><p> </p><p> rs=pst.executeQuery();</p><p> if(rs.next()){</p><p> JOptionPane.showMessageDialog(null, "Username and Password is correct");</p><p> rs.close();</p><p> pst.close();</p><p> close();</p><p> </p><p> Options s=new Options();</p><p> s.setVisible(true);</p><p> </p><p> }</p><p> else{</p><p> JOptionPane.showMessageDialog(null, "Username and Password is incorrect");</p><p> }</p><p> }</p><p> catch(Exception e)</p><p> {</p><p> JOptionPane.showMessageDialog(null, e);</p><p> </p><p> }</p><p> </p><p> } [/CODE]</p></blockquote><p></p>
[QUOTE="niyomax, post: 19016541, member: 514695"] meka kohomada balanna kauruhari (weda karanawa) mam keewe standard eka :P DB Class [CODE]package elakiri; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class DBClass { private static final String USERNAME= "root"; private static final String PASSWORD= ""; private static final String CONN_STRING= "jdbc:mysql://localhost:3306/exampleelakiri"; public static Connection ConnectDB() throws SQLException{ Connection conn=null; try{ conn=DriverManager.getConnection(CONN_STRING,USERNAME,PASSWORD); return conn; }catch(SQLException e){ System.err.println(e); } return null; } }[/CODE] login class ekema [CODE] public class LoginForm extends javax.swing.JFrame { Connection conn=null; ResultSet rs=null; PreparedStatement pst=null; public LoginForm() throws SQLException { initComponents(); conn= DBClass.ConnectDB(); }[/CODE] Button Action Perfomed ekata [CODE] private void cmd_loginActionPerformed(java.awt.event.ActionEvent evt) { String sql = "SELECT * from adminstbl where username=? and password=?"; try{ pst=conn.prepareStatement(sql); pst.setString(1, uname.getText()); pst.setString(2, pword.getText()); rs=pst.executeQuery(); if(rs.next()){ JOptionPane.showMessageDialog(null, "Username and Password is correct"); rs.close(); pst.close(); close(); Options s=new Options(); s.setVisible(true); } else{ JOptionPane.showMessageDialog(null, "Username and Password is incorrect"); } } catch(Exception e) { JOptionPane.showMessageDialog(null, e); } } [/CODE] [/QUOTE]
Insert quotes…
Verification
Hata thunen beduwama keeyada? (60 bedeema thuna)
Post reply
Top
Bottom