I was Writing a code to connect data base and add the following code to my action.java

Connection connection=getConnection("UserBook","UserBook123","catalog","localhost"); 
    String sql="select BookName from book"; 
    PreparedStatement ps=null; 
    ps=connection.PreparedStatement(sql);
    ResultSet set=ps.executeQuery(); 
    while(set!=null&&set.next()) { 
    System.out.println(set.getString("BookName")); } 
    connection.close(); 

the error i get is "The method PreparedStatement(String) is undefined for the type Connection"
Need to know how i can resolve this problem

I was Writing a code to connect data base and add the following code to my action.java

Connection connection=getConnection("UserBook","UserBook123","catalog","localhost"); 
        String sql="select BookName from book"; 
        PreparedStatement ps=null; 
        ps=connection.PreparedStatement(sql);
        ResultSet set=ps.executeQuery(); 
        while(set!=null&&set.next()) { 
        System.out.println(set.getString("BookName")); } 
        connection.close(); 

the error i get is "The method PreparedStatement(String) is undefined for the type Connection"
Need to know how i can resolve this problem

Spelling counts, and so does capitalization. I assume you want the prepareStatement function from Connection, which RETURNS a PreparedStatement. There are several, one of which takes a String.

http://www.j2ee.me/javase/6/docs/api/java/sql/Connection.html