Can't display from MySql

Hi,

I am trying to display the movietitle from my sql database->moviexpress,table name->movie.However the output i get from the jsp page is NULL.Can anyone tell mi why?

Thanx ^.^

<%

// database parameters

String host="localhost";

String user="tomcat";

String pass="tomcat";

String db="test";

String conn;

Class.forName("org.gjt.mm.mysql.Driver");

// create connection string

conn = "jdbc:mysql://" + host + "/" + db + "?user=" + user + "&password=" + pass;

// pass database parameters to JDBC driver

Connection Conn = DriverManager.getConnection(conn);

// query statement

Statement SQLStatement = Conn.createStatement();

String movietitle = request.getParameter("movietitle");

String Query = "SELECT movietitle FROM movie" ;

out.println(movietitle);

SQLStatement.close();

Conn.close();

%>

[950 byte] By [miN] at [2007-9-27 15:46:51]
# 1
HiTry thisString movietitle = request.getParameter("movietitle"); String Query = "SELECT "+movietitle+" FROM movie" ;out.println(movietitle);SQLStatement.close();Conn.close();ThanksSwaraj
kswaraj at 2007-7-5 23:57:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Hi,I try your code,the output still NULL, izzit i nv connect the database properly? Thanx
miN at 2007-7-5 23:57:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
your code "out.println(movietitle);" only print the query string got from request parameter, not the resultset from JDBC query. Did you manually try your query on db GUI? Maybe there is no such movie on ur db.
ytan022 at 2007-7-5 23:57:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
HiYou have not executed your resultSet at all, how do you expect to get values by just placing a query in a string ?try thisResultSet rs = st.executeQuery(query);while(!rs.next()){ out.println(rs.getString(1));}ThanksSwaraj
kswaraj at 2007-7-5 23:57:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

> String Query = "SELECT movietitle FROM movie" ;

> out.println(movietitle);

Use this code snippet,

String Query = "SELECT movietitle FROM movie" ;

ResultSet rs = SQLStatement.executeQuery(Query);

while(rs.next())

out.print(rs.getString("your_movie_title_column")+"

");

Sudha

sudha_mp at 2007-7-5 23:57:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Hi, I have tested those codes you all gave me, and it works, thanx for taking your time to teach me. Thank you veri much! v^.^v
miN at 2007-7-5 23:57:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...