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
ඕනම රටකට සෙට් වෙන CV එකක්
ErMurazor
Updated:
Saturday at 9:50 AM
Hambantota
7 Acres Beachfront Land For Sell DownSouth , PerPerch Price 420 000
1024 Digital
Updated:
Wednesday at 11:57 AM
Baseus PI LITE INDOOR CAMERA
ErMurazor
Updated:
Oct 12, 2026
Ad icon
Colombo
Hard Disk For Sale
mazza
Updated:
Oct 10, 2026
land for sale
justasking
Updated:
Oct 10, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
Computers & Internet
Software Development
Programming 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="B.Chat" data-source="post: 28491969" data-attributes="member: 578035"><p><span style="color: rgb(84, 172, 210)">(මේ ජවා ටිකේ රතුපාටින් තියෙන ටික මම Add කරා Duplicate නවත්තන්න. ඒත් ඒ ටික වැඩ නෑ. Error එකක් එන්නෙත් නෑ හැබැයි. මේකේ වැරැද්ද හොයා ගන්න පුලුවන් නම් කියන්න වැඩ්ඩෙක්. </span></p><p><span style="color: rgb(84, 172, 210)">MySQL Table Name - category</span></p><p><span style="color: rgb(84, 172, 210)">MySQL Table Field Names - id, category, status</span></p><p><span style="color: rgb(84, 172, 210)">Text fields on JFrame - txtcat , status(combobox) )</span></p><p></p><p>private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { </p><p> //Add a category , add button </p><p> </p><p> String category = txtcat.getText();</p><p> String status=txtstatus.getSelectedItem().toString();</p><p></p><p> //Duplicate check - not work</p><p> <span style="color: rgb(235, 107, 86)"> String dup = "SELECT category FROM category where category = '"+category+"'";</span></p><p><span style="color: rgb(235, 107, 86)"></span></p><p><span style="color: rgb(235, 107, 86)">if(dup.equals(category)){</span></p><p><span style="color: rgb(235, 107, 86)">JOptionPane.showMessageDialog(null,"Category Name is already existed! Please enter new one");</span></p><p><span style="color: rgb(235, 107, 86)">}</span></p><p><span style="color: rgb(235, 107, 86)">else{</span></p><p> </p><p> </p><p> try {</p><p> Class.forName("com.mysql.cj.jdbc.Driver");</p><p> con1=DriverManager.getConnection("jdbc:mysql://localhost/possystem","root",""); </p><p> pst = con1.prepareStatement("INSERT INTO category (category,status) VALUES (?,?)");</p><p> pst.setString(1, category);</p><p> pst.setString(2,status);</p><p> pst.executeUpdate();</p><p> JOptionPane.showMessageDialog(null,"Category Added" );</p><p> table_update();</p><p> txtcat.setText("");</p><p> txtstatus.setSelectedIndex(1);</p><p> txtcat.requestFocus();</p><p> </p><p> } catch (ClassNotFoundException ex) {</p><p> Logger.getLogger(category.class.getName()).log(Level.SEVERE, null, ex);</p><p> } catch (SQLException ex) {</p><p> Logger.getLogger(category.class.getName()).log(Level.SEVERE, null, ex);</p><p> }</p><p> </p><p>}</p></blockquote><p></p>
[QUOTE="B.Chat, post: 28491969, member: 578035"] [COLOR=rgb(84, 172, 210)](මේ ජවා ටිකේ රතුපාටින් තියෙන ටික මම Add කරා Duplicate නවත්තන්න. ඒත් ඒ ටික වැඩ නෑ. Error එකක් එන්නෙත් නෑ හැබැයි. මේකේ වැරැද්ද හොයා ගන්න පුලුවන් නම් කියන්න වැඩ්ඩෙක්. MySQL Table Name - category MySQL Table Field Names - id, category, status Text fields on JFrame - txtcat , status(combobox) )[/COLOR] private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { //Add a category , add button String category = txtcat.getText(); String status=txtstatus.getSelectedItem().toString(); //Duplicate check - not work [COLOR=rgb(235, 107, 86)] String dup = "SELECT category FROM category where category = '"+category+"'"; if(dup.equals(category)){ JOptionPane.showMessageDialog(null,"Category Name is already existed! Please enter new one"); } else{[/COLOR] try { Class.forName("com.mysql.cj.jdbc.Driver"); con1=DriverManager.getConnection("jdbc:mysql://localhost/possystem","root",""); pst = con1.prepareStatement("INSERT INTO category (category,status) VALUES (?,?)"); pst.setString(1, category); pst.setString(2,status); pst.executeUpdate(); JOptionPane.showMessageDialog(null,"Category Added" ); table_update(); txtcat.setText(""); txtstatus.setSelectedIndex(1); txtcat.requestFocus(); } catch (ClassNotFoundException ex) { Logger.getLogger(category.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(category.class.getName()).log(Level.SEVERE, null, ex); } } [/QUOTE]
Insert quotes…
Verification
Dawasata paya keeyak thibeda?
Post reply
Top
Bottom