Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
- I've created a Java class for the controller, called "pageController.java"
- Another java class that includes the date getter and setter, "pages.java"

- A JSP to display the date coding:
<label class="label" name="date" ></label>


The name "date" will pass to the getter and setter in pages.java:
C#
private String date;

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }
     public pages (){}  //just added


Lastly, the page Controller has (import pages.java)
C#
public class pageController {
    static Statement stmt = null;
    static Connection conn = null;

    public static void main(String[] args) throws SQLException{
        String connectionURL = "jdbc:mysql://localhost:8888/diario";
        pages p = new pages(); //edited here
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection(connectionURL, "root", "narumi");
            stmt = conn.createStatement();
            String sql;
            sql = "Select CURDATE() AS today";
            ResultSet rs = stmt.executeQuery(sql);

            while (rs.next()){
                p.setDate(rs.getString(1)); //p.setDate(rs.getString("today"));
            }
            rs.close();
            stmt.close();
            conn.close();
        }catch (SQLException e){
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}


After running the JSP, nothing shows. IDE I'm using is intelliJ IDEA 15
Posted
Updated 7-Dec-15 23:56pm
v3
Comments
ZurdoDev 7-Dec-15 10:33am    
Isn't getString() 0 based? So, you should have r.setDate(rs.getString(0));

Also, does your IDE have a debugger? If so, this should be pretty fast for you to find.
Hayashi Narumi 8-Dec-15 5:51am    
That also didn't work. But I've improved my question.
ZurdoDev 8-Dec-15 7:07am    
Does your IDE support breakpoints? If so, you should be able to figure out the problem very quickly.
TorstenH. 11-Dec-15 9:05am    
I think should try to find the date by java code...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900