im sorry i was mistaken.
ur right, i must have meant applying Stored Procedures on my JSP page...
here i have tcategory as my table with columns(Strings](category and location)
if the client adds an entry to my DB, what was the exact statement be use?
how will i use the callable statement?
an example code could help.
thx!
here a sample code snippet:
try{
Class.forName("some.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection(driver,uname,pword);
conn.setAutoCommit (false);
CallableStatement cs = conn.prepareCall("{call get_pword(?,?)}");
cs.setString(1,userName);
cs.registerOutParameter(2,Types.VARCHAR);
cs.execute();
password1 = cs.getString(2);
conn.close();
cs.close();
}catch(SQLException e){
e.printStackTrace();
}
[nobr]try
{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/market","root","");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from table");
while(rs.next()){
out.print(rs.getString(1)+"<br>");
}
conn.close();
} catch (Exception ex)
{
ex.printStackTrace();
}
[/nobr]
my JSP runs as a search page and this is whats inside my SP: (is it necessary to use callable statement to call this SP?)
CREATE PROCEDURE spGetCategory (@ID INT = 0 ,
@Category VARCHAR (20)= null ,
@Location VARCHAR (20)= null )
AS
SELECT *
FROM TCategory
WHERE ID = @ID
OR Category = @Category
OR Location = @Location