JSON on JSP (JDBC)

applying JSON on my JSP page, i want to do some SQL statement via JDBC.what are the methods? im really new to this approach. like if the client add/edit/delete an entry...what are the functions expected in my JSP page?
[239 byte] By [tata-yanga] at [2007-10-3 0:27:12]
# 1
what is JSON?
jgalacambraa at 2007-7-14 17:19:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
JSON JavaScript Object Notation
tata-yanga at 2007-7-14 17:19:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
wher do you think you can use JSON on JDBC?.. i cannot see the point
jgalacambraa at 2007-7-14 17:19:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

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!

tata-yanga at 2007-7-14 17:19:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
are you calling a procedure or a direct insert statement?.. those codes are different.
jgalacambraa at 2007-7-14 17:19:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
i want to use the stored procedure
tata-yanga at 2007-7-14 17:19:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

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();

}

jgalacambraa at 2007-7-14 17:19:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
thanks,but what will be my SQL statement to view the added entry?
tata-yanga at 2007-7-14 17:19:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9

[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]

jgalacambraa at 2007-7-14 17:19:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10
pls. provide callable statement example that can be applied on a search entry JSP application...with an int and string parameters.
tata-yanga at 2007-7-14 17:19:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 11
what i gave you is calling a procedure and a select(db query).. what you have in mind that i don't get?
jgalacambraa at 2007-7-14 17:19:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 12
this is what troubles me...When will i use the callable statement in my JSP? (yes im calling a stored procedure) whats the diff. between calling it directly and using a callable?
tata-yanga at 2007-7-14 17:19:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 13
what does you stored procedure do? querying(select) from db?
jgalacambraa at 2007-7-14 17:19:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 14

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

tata-yanga at 2007-7-14 17:19:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 15
> 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?)> yes.. but why still want to call stored procedure instead of simple query?..
jgalacambraa at 2007-7-21 9:06:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 16
i just like to know how my code goes when using SP's specially applying the callable statement for my future jsp applics...
tata-yanga at 2007-7-21 9:06:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 17
yeah:)
jgalacambraa at 2007-7-21 9:06:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 18
When is a callable statement use on JSP's?
tata-yanga at 2007-7-21 9:06:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 19
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/CallableStatement.
jgalacambraa at 2007-7-21 9:06:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...