Posts

Example.

public class c {     public static void main(String args[])     {     System.out.println("\u0905\u0905\u0940\u0924\u093E\u092A"); } }

Find Product and its Sub_product list through JComboBox Item State change.

 private void jComboBox2ItemStateChanged(java.awt.event.ItemEvent evt) {                                                     String name1=jComboBox2.getSelectedItem().toString();         String id=null;         try         {     Class.forName("com.mysql.jdbc.Driver");     java.sql.Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3305/inventory","root","root");     String sql="select BRANDID from brand where BRANDNAME='"+name1+"'";     java.sql.PreparedStatement pst=con.prepareStatement(sql);     ResultSet rs=pst.executeQuery();     while(rs.next())     {         id=rs.getString(1);     }     get(id);         }         catch(Exception e)         {             System.out.println(e);         }     }           public void get(String id) {         DefaultComboBoxModel model = new DefaultComboBoxModel();        try         {     Class.forName("co

Retrieve CSV file through java.

try         {            Class.forName("com.mysql.jdbc.Driver");            java.sql.Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3305/supplimentry","root","root");            String sql="LOAD DATA LOCAL INFILE 'h://inventory.csv'\n" +             "INTO TABLE inventory\n" +             "FIELDS TERMINATED BY ','\n" +             "OPTIONALLY ENCLOSED BY '\"'\n" +             "LINES TERMINATED BY '\n'";            java.sql.PreparedStatement pst1=con.prepareStatement(sql);            pst1.executeUpdate();            con.close();            pst1.close();            JOptionPane.showMessageDialog(null,"Restore Successfully!!!!");         }         catch(Exception e)         {             System.out.println(e);         }

create csv file through java.

    String sql2="SELECT * FROM inventory into outfile 'h:/inventory.csv' FIELDS TERMINATED BY ','\n" + "ENCLOSED BY '\"'\n" + "LINES TERMINATED BY '\\n';";         com.mysql.jdbc.PreparedStatement pst1=(com.mysql.jdbc.PreparedStatement) con.prepareStatement(sql2);         pst1.executeQuery();         pst1.close();         JOptionPane.showMessageDialog(null,"Go To H-Drive For CSV File");         Desktop.getDesktop().open(new File("h://inventory.csv"));    

Ceate CSV File through java.

   String sql2="SELECT * FROM inventory into outfile 'h:/inventory.csv' FIELDS TERMINATED BY ','\n" + "ENCLOSED BY '\"'\n" + "LINES TERMINATED BY '\\n';";         com.mysql.jdbc.PreparedStatement pst1=(com.mysql.jdbc.PreparedStatement) con.prepareStatement(sql2);         pst1.executeQuery();         pst1.close();         JOptionPane.showMessageDialog(null,"Go To H-Drive For CSV File");         Desktop.getDesktop().open(new File("h://inventory.csv"));    

Login Through Enter Button in java swing.

  if(evt.getKeyCode()==KeyEvent.VK_ENTER)       {             type=jComboBox1.getSelectedItem().toString(); if(type=="ADMIN") {         try        {            String cn=jTextField1.getText();            String pass=jPasswordField1.getText();            String type1=jComboBox1.getSelectedItem().toString();            if(cn.equals(""))            {                JOptionPane.showMessageDialog(null,"Pls Enter ur Name and Password");            }            else if(pass.equals(""))            {                JOptionPane.showMessageDialog(null,"Pls Enter ur Name and Password");            }                     else            {            Class.forName("com.mysql.jdbc.Driver");            java.sql.Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3305/supplimentry","root","root");            java.sql.PreparedStatement pst=con.prepareStatement("select nam

Pie Chart.

    public double gt()     {         double exp=0;         try         {           Class.forName("com.mysql.jdbc.Driver");            java.sql.Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3305/supplimentry","root","root");            String sql1="SELECT sum(Amount) as Amount from expenses";            java.sql.PreparedStatement pst1=con.prepareStatement(sql1);             ResultSet rs=pst1.executeQuery();            while(rs.next())             {             exp=rs.getDouble(1);             }         }         catch(Exception e)         {                    }         return exp;     }     public double it()     {         double exp=0;         try         {           Class.forName("com.mysql.jdbc.Driver");            java.sql.Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3305/supplimentry","root","root");            String sq

On Jtable Update.

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                               System.out.println("NAVEEN");         int row=jTable2.getSelectedRow();         System.out.println(""+row);         String t1=(jTable2.getModel().getValueAt(row, 0).toString());          System.out.println(""+t1); String name = (jTable2.getModel().getValueAt(row, 1).toString());  System.out.println(name); String mail = (jTable2.getModel().getValueAt(row, 2).toString()); String add = (jTable2.getModel().getValueAt(row, 3).toString());  System.out.println(add);      String pass = (jTable2.getModel().getValueAt(row, 4).toString());    System.out.println(pass);  try{   Class.forName("com.mysql.jdbc.Driver");     java.sql.Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3305/naveen","root","root");   String query = "update jtable set name=?,mail=?,address=?,passw

BarCode with Random Number.

import java.io.FileNotFoundException; import java.io.FileOutputStream; import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.itextpdf.text.PageSize; import com.itextpdf.text.Paragraph; import com.itextpdf.text.Rectangle; import com.itextpdf.text.pdf.Barcode128; import com.itextpdf.text.pdf.PdfWriter; import java.awt.Desktop; import java.io.File; import java.util.Random; //import com.lowagie.text.Document; //import com.lowagie.text.DocumentException; //import com.lowagie.text.PageSize; //import com.lowagie.text.Paragraph; //import com.lowagie.text.Rectangle; //import com.lowagie.text.pdf.Barcode128; //import com.lowagie.text.pdf.PdfWriter; public class BarCode128 {  public static void main(String[] args) throws FileNotFoundException, DocumentException {     Document document = new Document(new Rectangle(PageSize.A4));       PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("h:/Naveen3.pdf"));

itextpdf.jar

package barcode; /**  *  * @author NAVJYOTI  */ import java.io.FileNotFoundException; import java.io.FileOutputStream; import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.itextpdf.text.PageSize; import com.itextpdf.text.Paragraph; import com.itextpdf.text.Rectangle; import com.itextpdf.text.pdf.Barcode128; import com.itextpdf.text.pdf.PdfWriter; import java.awt.Desktop; import java.io.File; //import com.lowagie.text.Document; //import com.lowagie.text.DocumentException; //import com.lowagie.text.PageSize; //import com.lowagie.text.Paragraph; //import com.lowagie.text.Rectangle; //import com.lowagie.text.pdf.Barcode128; //import com.lowagie.text.pdf.PdfWriter; public class BarCode128 {  public static void main(String[] args) throws FileNotFoundException, DocumentException {     Document document = new Document(new Rectangle(PageSize.A4));       PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(&

Insert Data in Database with Batch with help of JTable.

/*  * To change this license header, choose License Headers in Project Properties.  * To change this template file, choose Tools | Templates  * and open the template in the editor.  */ package commity; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; import net.proteanit.sql.DbUtils; /**  *  * @author NAVJYOTI  */ public class JTableinsertintodatabase extends javax.swing.JFrame {     /**      * Creates new form JTableinsertintodatabase      */     public JTableinsertintodatabase() {         initComponents();         set();     }     /**      * 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"

Insert data in database through JTable.

package commity; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; import net.proteanit.sql.DbUtils; /**  *  * @author NAVJYOTI  */ public class JTableinsertintodatabase extends javax.swing.JFrame {     /**      * Creates new form JTableinsertintodatabase      */     public JTableinsertintodatabase() {         initComponents();         set();     }     /**      * 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() {         jScrollPane1 = new jav

Item State change of JComboBox and Get values from database and show Data on JTable.

 try     {     Class.forName("com.mysql.jdbc.Driver");     java.sql.Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3305/supplimentry","root","root");     String sql="select * from inventory where Brand_Name='"+jComboBox3.getSelectedItem().toString()+"'";     java.sql.PreparedStatement pst=con.prepareStatement(sql);     DefaultTableModel tm33 = (DefaultTableModel)list1.getModel();     tm33.setRowCount(0);  TableColumn col = new TableColumn(tm33.getColumnCount());  JTableHeader header = list1.getTableHeader();   header.setBackground(Color.yellow);        ResultSet rs = pst.executeQuery(sql);     int i=0;     while(rs.next())     {     Vector v2 = new Vector();     v2.addElement(rs.getString(1));     v2.addElement(rs.getString(2));     v2.addElement(rs.getInt(3));     v2.addElement(rs.getDouble(4));     v2.addElement(rs.getDouble(5));     v2.addElement(rs.getDouble(6));     v2.

jComboBox2 ItemStateChanged.

  private void jComboBox2ItemStateChanged(java.awt.event.ItemEvent evt) {                                           String name=jComboBox2.getSelectedItem().toString(); if(name.equals("Bristish Nutrition")) {     jTextField1.setText("BN"); } else if(name.equals("Muscle Blaze")) {     jTextField1.setText("MB"); }     }  

Add Product Through yes no option

int p=JOptionPane.showConfirmDialog(null,"Do U Want to Add","Add Product",JOptionPane.YES_NO_OPTION);       if(p==0)       {         try        {            Class.forName("com.mysql.jdbc.Driver");            java.sql.Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3305/supplimentry","root","root");            java.sql.PreparedStatement pst1=con.prepareStatement("select * from inventory where Product_Code='"+jTextField2.getText()+"'");            ResultSet rs=pst1.executeQuery();            if(rs.next())            {               JOptionPane.showMessageDialog(null,"Already Exists!!");               con.close();               pst1.close();               rs.close();            }            else            {                java.sql.Date sqldate = new java.sql.Date(jd1.getDate().getTime());                String sql="insert into inventory(Product_Co