Thursday, 8 August 2013

Custom Date Picker in java

Hi!


                 Like php,android,etc.., their is no UI for Date Picker in Java we have to build manually by calling java.util.Calendar class,

now i place my own date picker as a .jar file. Now you can download and add this jar into your project..,

You can Download Here..,


How to use it!


  • Assign variable for ui,
  • Create an object,
  • Call the datepicker class directly.

JLabel register_date = new JLabel();

register_date.setText(new DatePicker(NewJFrame).setPickedDate());


Thank You..,

Wednesday, 7 August 2013

How to Configure Eclips-Weblogic Server

Hi!


I show how the simple way to configure Eclipse - weblogic Server..,

watch it & fallow it..,




Thank You..,

Upload Data from .CSV Formate into Data Base


Hi!


In previous blog i show how to download data from database into Excel / .csv formate.
Now in this blog i show you how to Upload the data from .csv formate into database.

.CSV formate is one of the secured formate to save data.

here i give an example code how to convert it.

i am using apache poi external jar for this process.

You can download from apache site.

simply i am calling the record from the MySQL Server, while if it is true then i pass those result-set through the poi


have to pass the header of your .csv column and align your column and the row




Statement stmt;
    String query;    try {        Class.forName("com.mysql.jdbc.Driver");        Connection conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/readmain", "root", "root");        stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);        String dds = JOptionPane.showInputDialog(null, "Enter FileName To Load", "");        if (!dds.equals("")) {            String fn = "C:/" + dds + ".csv";            query = "LOAD DATA INFILE '" + fn + "' INTO TABLE salarydet FIELDS TERMINATED BY ',' (EmployeeId,Saldate,Basic,Additionalpay,Spl,Other,Leavem,Gross,Netsal,Laveded,Loanamt,Festiveladv,Traveladv,Salaryadv,Othersded,Totded,Insurance)";            stmt.executeUpdate(query);            JOptionPane.showMessageDialog(null, "Uploaded Sceeceefully");        } else {
            JOptionPane.showMessageDialog(null, "Check Your File Please");
        }
    } catch (Exception r) {
        JOptionPane.showMessageDialog(null, "Check Your File Please");
    }


Thank You!

Have A Happy Day..,

Convert / Download Data from Data Base into .CSV Formate


Hi!


In this blog i show you how to convert the data from database into .csv formate.

.CSV formate is one of the secured formate to save data.

here i give an example code how to convert it.

i am using apache poi external jar for this process.

You can download from apache site.

simply i am calling the record from the MySQL Server, while if it is true then i pass those result-set through the poi


have to pass the header of your .csv column and align your column and the row


try {
        DateFormat format = new SimpleDateFormat("dd/MM/yyyy");        java.util.Date date = format.parse(new DatePicker(NewJFrame).setPickedDate());        java.sql.Date sqlD = new java.sql.Date(date.getTime());        Class.forName("com.mysql.jdbc.Driver");        Connection connn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/readmain", "root", "root");        PreparedStatement ps100 = connn.prepareStatement("select Saldate from salarydet where Saldate ='" + sqlD + "'");        ResultSet rs100 = ps100.executeQuery();        if (rs100.next()) {            try {                Class.forName("com.mysql.jdbc.Driver");                Connection conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/readmain", "root", "root");                String mn = JOptionPane.showInputDialog(null, "Enter File Name", "");
                if (!mn.equals("")) {
                    String mnd = "C:/" + mn + ".CSV";
                    Object dd = gtempid.getSelectedItem();
                    PreparedStatement ps = conn.prepareStatement("SELECT * INTO OUTFILE '" + mnd + "' FIELDS TERMINATED BY ',' FROM salarydet where Saldate ='" + sqlD + "';");
                    ps.executeQuery();
                    conn.close();
                    JOptionPane.showMessageDialog(null, " CSV File Saved On c:/");
                } else {
                    JOptionPane.showMessageDialog(null, "Enter Valid File Name");
                }
            } catch (Exception r) {
                JOptionPane.showMessageDialog(null, "Process Is Canceled & Check Your File Name");
            }
        } else {
            JOptionPane.showMessageDialog(null, "Select Correct Date Please");
        }
    } catch (Exception e) {
    }


Thank You!..,

Convert / Download Data from Data Base into Excel Formate


Hi!


Commonly facing an issue to convert the data from database into Excel formate.


here i give an example code how to convert it.

i am using apache poi external jar for this process.

You can download from apache site.

simply i am calling the record from the MySQL Server, while if it is true then i pass those result-set through the poi


have to pass the header of your excel column and align your column and the row



try 
   { 
HSSFWorkbook xlsWorkbook = new HSSFWorkbook();                      HSSFSheet xlsSheet = xlsWorkbook.createSheet();                short rowIndex = 0;                Class.forName("com.mysql.jdbc.Driver"); 
Connection conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/readmain", "root", "root");
PreparedStatement stmt = conn.prepareStatement("select EmployeeId,Name,Department,Designation,Branch,DATE_FORMAT(Saldate, '%d/%m/%Y') as Saldate,LeaveTaken,Basic,Additionalpay,Spl,Other,Gross,Netsal,Insurance,Laveded,Loanamt,Festiveladv,Traveladv,Salaryadv,Othersded,Totded from newsal where EmployeeId ='" + ide + "' ORDER BY Saldate desc");// ORDER BY Saldate desc");
                ResultSet rs = stmt.executeQuery();
                ResultSetMetaData colInfo = rs.getMetaData();
                List<String> colNames = new ArrayList<String>();
                HSSFRow titleRow = xlsSheet.createRow(rowIndex++);
                for (int i = 1; i <= colInfo.getColumnCount(); i++) {
                    colNames.add(colInfo.getColumnName(i));
                    titleRow.createCell((short) (i - 1)).setCellValue(
                            new HSSFRichTextString(colInfo.getColumnName(i)));
                    xlsSheet.setColumnWidth((short) (i - 1), (short) 4000);
                }
                while (rs.next()) {
                    HSSFRow dataRow = xlsSheet.createRow(rowIndex++);
                    short colIndex = 0;
                    for (String colName : colNames) {
                        dataRow.createCell(colIndex++).setCellValue(
                                new HSSFRichTextString(rs.getString(colName)));
                    }
                }
                String mn = JOptionPane.showInputDialog("Enter File Name To Save On C:/Excell/", "");
                if (!mn.equals("")) {
                    xlsWorkbook.write(new FileOutputStream(new File("C:/Excell/" + mn + ".xls")));
                    JOptionPane.showMessageDialog(null, mn + " Is Save On C:/Excell/");
                    conn.close();
                } else {
                    JOptionPane.showMessageDialog(null, "Enter File Name");
                }
            } catch (Exception r) {
                JOptionPane.showMessageDialog(null, "You Cancell The Process");
            }


        } else {
            JOptionPane.showMessageDialog(null, "Enter Valid ID Please");
        }
    } 

now you can easily download your record's into excel formate.

Thank You!

Have A happy Day..,