Retrieve Data on Month in MySql
d5 = ((JTextField)jDateChooser1.getDateEditor().getUiComponent()).getText();
Calendar c = Calendar.getInstance();
try {
c.setTime(sdf.parse(d5));
month1 = c.get(Calendar.MONTH)+1;
System.out.println(month1);
} catch (ParseException ex) {
Logger.getLogger(Commity.class.getName()).log(Level.SEVERE, null, ex);
}
try
{
Class.forName("com.mysql.jdbc.Driver");
java.sql.Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3305/commity","root","root");
String sql="select MemberName,Group_Number,Payment from insatllment where MONTH(Date)='"+month1+"' and Group_Number='"+jTextField13.getText()+"'";
java.sql.PreparedStatement pst=con.prepareStatement(sql);
ResultSet rs = pst.executeQuery(sql);
countdate.setModel(DbUtils.resultSetToTableModel(rs));
con.close();
pst.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e);
}
Calendar c = Calendar.getInstance();
try {
c.setTime(sdf.parse(d5));
month1 = c.get(Calendar.MONTH)+1;
System.out.println(month1);
} catch (ParseException ex) {
Logger.getLogger(Commity.class.getName()).log(Level.SEVERE, null, ex);
}
try
{
Class.forName("com.mysql.jdbc.Driver");
java.sql.Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3305/commity","root","root");
String sql="select MemberName,Group_Number,Payment from insatllment where MONTH(Date)='"+month1+"' and Group_Number='"+jTextField13.getText()+"'";
java.sql.PreparedStatement pst=con.prepareStatement(sql);
ResultSet rs = pst.executeQuery(sql);
countdate.setModel(DbUtils.resultSetToTableModel(rs));
con.close();
pst.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e);
}