Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Calendar cal = Calendar.getInstance();
- int year = cal.get(Calendar.YEAR); // The current year as an int
- int month = (cal.get(Calendar.MONTH) + 1);
- String tahun_ntpd = Integer.toString(year);
- String bulan_ntpd = Integer.toString(month);
- String test="";
- try{
- Class.forName("com.mysql.jdbc.Driver");
- Connection con=DriverManager.getConnection(
- "jdbc:mysql://localhost:3306/masterpendapatan","root","");
- //here sonoo is database name, root is username and password
- Statement stmt=con.createStatement();
- ResultSet rs=stmt.executeQuery("select * from ntpd where year = '" + year +"' and month = '" + month +"'");
- //PreparedStatement stmt = con.prepareStatement("select * from ntpd where year = '" + tahun_ntpd +"' and month = '" + bulan_ntpd +"'");
- //ResultSet rs = stmt.executeQuery();
- //System.out.println(rs);
- while(rs.next())
- System.out.println(year);
- test += rs.getString(2);
- con.close();
- }catch(Exception e){
- log.error("Some exception has been thrown", e);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement